wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Programming Quiz

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the output of the following code?

a)

Hello World

b)

HelloWorld

c)

Hello+World

d)

None of the above

2.

What is the output of the following code?

a)

12

b)

13

c)

14

d)

15

3.

What is the output of the following code?

a)

[1, 2, 3]

b)

[1, 2, 3, 4]

c)

[4]

d)

Error

4.

What is the output of the following code?

a)

[2, 4, 6]

b)

[1, 2, 3, 1, 2, 3]

c)

[1, 1, 2, 2, 3, 3]

d)

Error

5.

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

a)

list = (1, 2, 3)

b)

list = [1, 2, 3]

c)

list = {1, 2, 3}

d)

list = <1, 2, 3>

6.

How do you declare a variable x with the value 10 in Python?

a)

int x = 10

b)

x := 10

c)

x = 10

d)

declare x = 10

7.

What is the output of the following code?

a)

[0, 1, 2, 3, 4]

b)

[1, 2, 3, 4, 5]

c)

[0, 1, 2, 3, 4, 5]

d)

[5, 4, 3, 2, 1]

8.

What does str[::-1] do in Python?

a)

Reverses the string str

b)

Removes the first character of the string str

c)

Repeats the string str

d)

Converts the string str to uppercase

9.

Which function is used to generate random numbers in Python?

a)

random.rand()

b)

random()

c)

random.randint()

d)

rand()

10.

What is a lambda function in Python?

a)

A named function

b)

An anonymous function

c)

A class method

d)

A recursive function