wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Programming Quiz

Total questions: 19

Worksheet time: 38mins

Name
Class
Date
1.

What is the standard file extension for a Python source file?

a)

.pt

b)

.py

c)

.python

d)

.p

2.

Which statement about Python is true?

a)

Python code must always be compiled before it can run.

b)

Python can only be used on Linux systems.

c)

Python is an interpreted, high-level programming language.

d)

Python cannot work with text data.

3.

Which function is used to display text on the screen in Python?

a)

echo()

b)

out()

c)

print()

d)

show()

4.

What is the result of the expression 3 + 4 * 2 in Python?

a)

14

b)

11

c)

7

d)

3

5.

Which of the following is an integer (int) value in Python?

a)

"5"

b)

5.0

c)

5

d)

True

6.

How does a single-line comment start in Python?

a)

//

b)

/*

c)

#

d)

--

7.

Which line shows a correct assignment statement?

a)

x == 5

b)

5 = x

c)

x = 5

d)

int x = 5

8.

Which of the following is a list in Python?

a)

{1, 2, 3}

b)

[1, 2, 3]

c)

(1, 2, 3)

d)

"1, 2, 3"

9.

What is the value of len("python")?

a)

5

b)

6

c)

7

d)

It causes an error.

10.

Which operator is used for the remainder (modulo) operation?

a)

//

b)

**

c)

%

d)

#

11.

What sequence of numbers is produced by range(3)?

a)

1, 2, 3

b)

0, 1, 2

c)

0, 1, 2, 3

d)

1, 2

12.

Which keyword is used to define a function in Python?

a)

func

b)

define

c)

def

d)

function

13.

Which of the following is a Boolean value?

a)

"True"

b)

1

c)

True

d)

"False"

14.

In the line if x > 0:, what is x > 0 called?

a)

a block

b)

a condition

c)

a loop

d)

a function

15.

How many times does the loop run? for i in range(5): print(i)

a)

4 times

b)

5 times

c)

6 times

d)

It runs forever.

16.

Which of the following is a dictionary (dict) in Python?

a)

[1, 2, 3]

b)

("name", "Ali")

c)

{"name": "Ali", "age": 15}

d)

{"Ali", "Veli"}

17.

What is the type of the value returned by type(3.5)?

a)

int

b)

float

c)

str

d)

bool

18.

What is the output of "python".upper()?

a)

python

b)

PYTHON

c)

Python

d)

It causes an error.

19.

Which list method removes the last element from a list?

a)

remove()

b)

delete()

c)

pop()

d)

cut()