wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python MCQ

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What is a correct syntax to output "Hello World" in Python?

a)

print("Hello World")

b)

p("Hello World")

c)

echo "Hello World"

d)

echo("Hello World");

2.

How do you insert COMMENTS in Python code?

a)

#This is a comment

b)

//This is a comment

c)

/*This is a comment*/

3.

Which one is NOT a legal variable name?

a)

my-var

b)

my_var

c)

Myvar

d)

_myvar

4.

How do you create a variable with the numeric value 5?

a)

x = int(5)

b)

x = 5

c)

Both the other answers are correct

5.

What is the correct file extension for Python files?

a)

.py

b)

.pt

c)

.pyt

d)

.pyth

6.

How do you create a variable with the floating number 2.8?

a)

x = 2.8

b)

x = float(2.8)

c)

Both the other answers are correct

7.

What is the correct syntax to output the type of a variable or object in Python?

a)

print(typeof(x))

b)

print(typeOf(x))

c)

print(type(x))

d)

print(typeof x)

8.

What is the correct way to create a function in Python?

a)

def myFunction():

b)

create myFunction():

c)

function myfunction():

9.

In Python, 'Hello', is the same as "Hello"

a)

True

b)

False

10.

Which operator can be used to compare two values?

a)

==

b)

<>

c)

><

d)

=

11.

Which of these collections defines a LIST?

a)

["apple", "banana", "cherry"]

b)

{"name": "apple", "color": "green"}

c)

{"apple", "banana", "cherry"}

d)

("apple", "banana", "cherry")

12.

Which of these collections defines a DICTIONARY?

a)

{"name": "apple", "color": "green"}

b)

["apple", "banana", "cherry"]

c)

{"apple", "banana", "cherry"}

d)

("apple", "banana", "cherry")

13.

Which collection is ordered, changeable, and allows duplicate members?

a)

SET

b)

DICTIONARY

c)

TUPLE

d)

LIST

14.

How do you start writing an if statement in Python?

a)

if x > y:

b)

if x > y then:

c)

if (x > y)

15.

Which statement is used to stop a loop?

a)

break

b)

stop

c)

exit

d)

return

16.

Which of the following is an invalid variable?

a)

my_string_1

b)

b) 1st_string

c)

foo

d)

_

17.

Which of the following is an invalid statement?

a)

abc = 1,000,000

b)

a b c = 1000 2000 3000

c)

a,b,c = 1000, 2000, 3000

d)

a_b_c = 1,000,000

18.

What is answer of this expression, 22 % 3 is?

a)

7

b)

1

c)

5

d)

0

19.

What dataype is the object below ?

a)

List

b)

dictionary

c)

array

d)

tuple

20.

What is the maximum possible length of an identifier?

a)

31 characters

b)

63 characters

c)

79 characters

d)

none of the mentioned