wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Quiz

Total questions: 12

Worksheet time: 6mins

Name
Class
Date
1.

Which keyword allows us to load a module in Python?

a)

Import

b)

Load

c)

Include

d)

Library

2.

What will be the output of the following code snippet?

print(2**3 + (5 + 6)**(1 + 1))

a)

8

b)

121

c)

129

d)

127

3.

How is a code block indicated in Python?

a)

Brackets

b)

Indentation

c)

Key pair

d)

colon

4.

What will be the output of the following code snippet?

a)

Infinite Loop

b)

0 3 6 9 12

c)

0 3 6 9 12 15

d)

0 2 3 ... 15

5.

Which of the following types of loops are not supported in Python?

a)

do while

b)

while

c)

for

d)

None

6.

a = [1, 2]

print(a * 3)

a)

Error

b)

[1,2]

c)

[1,2,1,2]

d)

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

7.

All keywords in Python are in _________

a)

Capitalized

b)

lowercase

c)

UPPERCASE

d)

NONE MENTIONED

8.

What will be the value of the following Python expression?

4 + 3 % 5

a)

4

b)

2

c)

1

d)

7

9.

What will be the output of the following Python code?

import datetime

print(datetime.date(2016,7,24))

a)

Error

b)

2016-07-24

c)

2017-7-24

d)

24-7-2016

10.

Which module in Python supports regular expressions?

a)

regex

b)

re

c)

pyregrex

d)

ree

11.

What does the function re.match do?

a)

matches a pattern at the start of the string

b)

matches a pattern at any position in the string

c)

such a function does not exist

d)

none mentioned

12.

Which of the following can be used to open a file called myText.txt in read-only mode?

a)

infile = open("myText.txt", “w”)

b)

infile = open("myText.txt", r)

c)

infile = open("myText.txt", “read”)

d)

infile = open("myText.txt")