wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Programming Quiz

Total questions: 13

Worksheet time: 3hrs 1mins

Name
Class
Date
1.

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

a)

function myFunc():

b)

def myFunc():

c)

func myFunc():

d)

define myFunc():

2.

Which data type is immutable in Python?

a)

List

b)

Dictionary

c)

String

d)

Set

3.

What is the correct way to check if "apple" exists as a key in fruits = {"apple": 1, "banana": 2}?

a)

"apple" in fruits

b)

fruits.has_key("apple")

c)

"apple" exists in fruits

d)

if fruits("apple"):

4.

What is the output of bool([]) in Python?

a)

True

b)

False

c)

None

d)

Error

5.

Which statement is used to handle exceptions in Python?

a)

catch

b)

try-except

c)

error

d)

handle

6.

What is the result of 3 * "Python"?

a)

"PythonPythonPython"

b)

["Python", "Python", "Python"]

c)

Error

d)

("Python", "Python", "Python")

7.

Is Python a case-sensitive language?

a)

Yes

b)

No

8.

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

a)

_myVar

b)

2ndValue

c)

my_variable

d)

variable2

9.

What happens when executing x = 5; y = "hello"; x, y = y, x

a)

Error

b)

x becomes "hello" and y becomes 5

c)

y becomes "hello" and x remains 5

d)

No change

10.

What will be the output of the following code?

a)

2 5 8

b)

2 3 4 5 6 7 8 9

c)

2 4 6 8 10

d)

2 6 10

11.

Explain the differences between Python’s list, tuple, and set.

4 lines
12.

List any Python keywords you can remember.

2 lines
13.

Describe Python in one word.

2 lines