Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python revision

Total questions: 15

Worksheet time: 11mins

Name
Class
Date
1.

What is the output of this code?

a)

1

b)

2

c)

"a"

d)

Error

2.

Which of the following creates a dictionary?

a)

{"apple", 1}

b)

["apple": 1]

c)

{"apple": 1}

d)

(apple:1)

3.

How do you add a new key-value pair to a dictionary?

a)

my_dict.add("color", "blue")

b)

my_dict["color"] = "blue"

c)

my_dict("color") = "blue"

d)

my_dict += {"color": "blue"}

4.

What will this code print?

a)

1

b)

2

c)

10

d)

20

5.

What is the result of this code?

a)

5

b)

7

c)

3

d)

2

6.

Which line causes an error?

a)

{"a": 1, "b": 2}

b)

d={"a": 1, "b": 2}

c)

print(d["c"])

d)

None

7.

What does this function return?

a)

None

b)

Hi!

c)

greet

d)

Error

8.

Which keyword is used to define a function?

a)

fun

b)

define

c)

def

d)

func

9.

How do you call this function?

a)

hello

b)

hello[ ]

c)

hello( )

d)

call hello

10.

What is the output?

a)

7

b)

34

c)

a + b

d)

error

11.

Which line defines a function with one parameter?

a)

def my_func[x]:

b)

def my_func(x):

c)

def my_func x:

d)

my_func def(x)

12.

What is the output?

a)

10

b)

25

c)

5

d)

x *x

13.

What does this code do?

a)

Shows error

b)

Returns value

c)

Prints Done when called

d)

Defines nothing

14.

What is the output of this?

a)

10

b)

9

c)

1

d)

11

15.

Which line is invalid?

a)

def my_func():

b)

print("Hello")

c)

return 5

d)

def (x, y):