NEW
Font size
WorksheetsPython 1 Quiz
Total questions: 25
Worksheet time: 50mins
What is a correct syntax to output "Hello World" in Python?
echo "Hello World"
p("Hello World")
print("Hello World")
output("Hello World");
How do you insert COMMENTS in Python code?
/*This is a comment*/
//This is a comment
#This is a comment
//This is a comment//
Which one is NOT a legal variable name?
my-var
_myvar
Myvar
my_var
How do you create a variable with the numeric value 5?
A. x = 5
B. x = int(5)
Both A & B are correct
C. x = five
What is the correct file extension for Python files?
.pyth
.pyt
.py
.pt
How do you create a variable with the floating number 2.8?
A. x = float(2.8)
B. x = int(2.8)
C. x = 2.8
Both A & C are correct
What is the correct syntax to output the type of a variable or object in Python?
print(type(x))
print(typeOf(x))
print(typeof(x))
print(typeof x)
What is the correct way to create a function in Python?
def myFunction():
create myFunction():
function myfunction():
make my_function[ ]:
In Python, 'Hello my friends!', is the same as "Hello my friends!"
True
False
What is a correct syntax to return the first character in a string?
x = sub("Hello", 0, 1)
x = "Hello".sub(0, 1)
x = "Hello"[0]
Which method can be used to return a string in upper case letters?
toUpperCase()
upperCase()
upper()
uppercase()
Which method can be used to replace parts of a string?
switch()
replace()
replaceString()
repl()
Which operator is used to multiply numbers?
%
#
*
x
Which operator can be used to compare two values?
> <
=
< >
==
Which of these collections defines a LIST?
{"apple", "banana", "cherry"}
["apple", "banana", "cherry"]
{"name": "apple", "color": "green"}
("apple", "banana", "cherry")
Which of these collections defines a TUPLE?
["apple", "banana", "cherry"]
{"name": "apple", "color": "green"}
{"apple", "banana", "cherry"}
("apple", "banana", "cherry")
How do you start writing an if statement in Python?
if x > y:
if x > y then:
if (x > y)
what if (x > y):
Which Python list types allow duplicates?
A. List
B. Dictionary
C. Tuple
D. Organized
E. Both A & C are correct
How do you convert to an Integer?
cheese = "3"
cheese = int("3")
print(cheese)
fries = 30
fries = str(30)
print(fries)
pizza = 4
pizza = float(4)
print(pizza)
class = "7"
class = integer(7)
print(class)
True or False: It's okay if your indentation isn't lined up in Python, it won't affect how your code runs.
True
False
What statement will catch everything that is not included in the IF statement?
The CATCH statement
The ELSE statement
The OTHER statement
The THEN statement
What is the output of this code?
rocks = 15
print(rocks / 5)
5
3
Three
rocks, rocks, rocks
In the code "for x in desserts:" what does the x mean?
It's declaring a new variable.
It's adding the letter x to the list.
Literally, the letter x.
It represents each item in the list in turn.
True or False: The code to be executed inside the for loop does not have to be indented.
True
False
In the image, what will the code print out?
I love to play volleyball I love to play basketball I love to play soccer
soccer basketball volleyball
x
I love to play soccer I love to play basketball I love to play volleyball
