wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PythonQuizOnKeywordsVariablesExpressionsOperators&Statements

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

Number of keywords supported by Python 3.9 and later

a)

34

b)

35

c)

36

d)

37

2.

What is the purpose of the Python keyword def?

a)

To define a variable

b)

To define a class

c)

To define a function

d)

To define a loop

3.

Choose the correct answer/answers related to Python programming.

a)

created by Guido van Rossum

b)

released on February 20, 1991

c)

the python is a large snake

d)

it came from BBC television comedy sketch series called Monty Python's Flying Circus.

4.

Which of the following is not a Python keyword

a)

lambda

b)

assert

c)

eval

d)

global

5.

Which keyword is used to exit a loop prematurely in Python

a)

continue

b)

pass

c)

break

d)

yield

6.

Which keyword is used for conditional statements in Python

a)

for

b)

while

c)

if

d)

try

7.

Does the python uses compiler or interpreter

a)

compiler

b)

interpreter

c)

both compiler and interpreter

8.

Python interpreter called as

a)

bytecode interpreter

b)

byte code virtual machine

c)

python virtual machine

d)

byte code compiler

9.

Which type of language python is? choose your answer/answers.

a)

High-level

b)

General-purpose

c)

Interpreted and Dynamic Semantics

d)

Object-oriented

10.

What does the Python keyword yield primarily do

a)

Creates a new function

b)

Defines a loop

c)

Returns a value from a generator function

d)

Raises an exception

11.

Which of the following is an example of a Python expression

a)

print("Hello")

b)

x = 10

c)

a + b

d)

if x > 5:

12.

Which of the following is an example of a Python statement? 

a)

5 * 2

b)

name == "Alice"

c)

for item in my_list:

d)

True and False

13.

What is the result of the following expression: 10 // 3

a)

3.33

b)

3

c)

1

d)

Error

14.

What will be the output of the following code snippet of Python

x = 5
y = 2
print(x ** y)

a)

7

b)

10

c)

25

d)

3

15.

Which of the following is a valid assignment statement in Python?

a)

x + y = z

b)

10 = num

c)

result = a * b

d)

if condition = True:

16.

What is the purpose of the pass statement in Python? 

a)

To skip the current iteration of a loop

b)

To exit a function

c)

To act as a placeholder where a statement is syntactically required but no action is desired

d)

To raise an exception. 

17.

Which of the following is a valid variable name in Python?

a)

1variable

b)


my-variable

c)


_my_variable

d)

class 

18.

What is a variable in Python?

a)

reserved keyword

b)

A data type

c)

A named location in memory to store data

d)

A function

19.

Which symbol is used to assign a value to a variable in Python? 

a)

:

b)

=

c)

#

d)

$

20.

In Python, are variable names case-sensitive?

a)

Yes

b)

No

c)

Only for certain data types

d)

It depends on the operating system

21.

Which of the following is an invalid variable name in Python? 

a)


1st
attempt

b)

my_variable

c)

score

d)

totalSales

22.

What will be the output of the following code of Python

x = 10
y = x
x += 5
print(y)

a)

10

b)

15

c)

Error

d)

None

23.

Which of the following is not a valid way to create multiple variables in one line with the same value?

a)

s t u = 5

b)


p = 10; q = 10; r = 10

c)


a, b, c = 1, 2, 3

d)

x = y = z = 0

24.

Which operator is used to calculate the remainder of a division? 

a)

%

b)

//

c)

/

d)

**

25.

What is the result of the expression 4 < 5 and 5 < 6? 

a)

True

b)

False

c)

Error

d)

None of the above