NEW
Font size
WorksheetsPython MCQ
Total questions: 20
Worksheet time: 10mins
What is a correct syntax to output "Hello World" in Python?
print("Hello World")
p("Hello World")
echo "Hello World"
echo("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?
x = int(5)
x = 5
Both the other answers are correct
What is the correct file extension for Python files?
.py
.pt
.pyt
.pyth
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(typeOf(x))
print(type(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 operator can be used to compare two values?
==
<>
><
=
Which of these collections defines a LIST?
["apple", "banana", "cherry"]
{"name": "apple", "color": "green"}
{"apple", "banana", "cherry"}
("apple", "banana", "cherry")
Which of these collections defines a DICTIONARY?
{"name": "apple", "color": "green"}
["apple", "banana", "cherry"]
{"apple", "banana", "cherry"}
("apple", "banana", "cherry")
Which collection is ordered, changeable, and allows duplicate members?
SET
DICTIONARY
TUPLE
LIST
How do you start writing an if statement in Python?
if x > y:
if x > y then:
if (x > y)
Which statement is used to stop a loop?
break
stop
exit
return
Which of the following is an invalid variable?
my_string_1
b) 1st_string
foo
_
Which of the following is an invalid statement?
abc = 1,000,000
a b c = 1000 2000 3000
a,b,c = 1000, 2000, 3000
a_b_c = 1,000,000
What is answer of this expression, 22 % 3 is?
7
1
5
0
What dataype is the object below ?
List
dictionary
array
tuple
What is the maximum possible length of an identifier?
31 characters
63 characters
79 characters
none of the mentioned
