WorksheetsPython XM
Total questions: 22
Worksheet time: 11mins
What is a correct syntax to output "Hello World" in Python?
echo("Hello World");
print("Hello World")
echo "Hello World"
p("Hello World)
How do you insert COMMENTS in Python code?
#This is a comment
//This is a comment
/*This is a comment*/
Which one is NOT a legal variable name?
my_var
my-var
_myvar
Myvar
How do you create a variable with the numeric value 5?
Both the other answers are correct
x = 5
x = int(5)
What is the correct file extension for Python files?
.pyt
.pyth
.py
.pt
How do you create a variable with the floating number 2.8?
x = 2.8
x = float(2.8)
Both the other answers are correct
What is the correct syntax to output the type of a variable or object in Python?
print(typeof x)
print(type(x))
print(typeof(x))
print(typeOf(x))
What is the correct way to create a function in Python?
def myFunction():
create myFunction():
function myfunction():
In Python, 'Hello', is the same as "Hello"
True
False
Which method can be used to return a string in upper case letters?
uppercase()
upperCase()
toUpperCase()
upper()
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"}
["apple", "banana", "cherry"]
("apple", "banana", "cherry")
{"name": "apple", "color": "green"}
Which of these collections defines a SET?
{"apple", "banana", "cherry"}
["apple", "banana", "cherry"]
("apple", "banana", "cherry")
{"name": "apple", "color": "green"}
Which of these collections defines a DICTIONARY?
{"apple", "banana", "cherry"}
["apple", "banana", "cherry"]
("apple", "banana", "cherry")
{"name": "apple", "color": "green"}
Which collection is ordered, changeable, and allows duplicate members?
TUPLE
LIST
DICTIONARY
SET
Which collection does not allow duplicate members?
TUPLE
LIST
SET
How do you start writing an if statement in Python?
if x > y then:
if x > y:
if (x > y)
How do you start writing a while loop in Python?
while (x > y)
while x > y:
while x > y {
x > y while {
How do you start writing a for loop in Python?
for x > y:
for x in y:
for each x in y:
Which statement is used to stop a loop?
stop
break
return
exit
