wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Quiz

Total questions: 15

Worksheet time: 5mins

Name
Class
Date
1.

What do For Loops do?

a)

A programming structure used to repeat actions without the player needing to write the same lines of code over and over.

b)

Data about or belonging to an object.

c)

Repeat a block of code while a certain condition is true.

d)

Repeat a block of code a certain number of times.

2.

What will the following code output?

myTuple = [(1, 2), (3, 4), (5, 6)]

for (a, b) in myTuple :

- print(a + b)

a)

1,2,3,4,5,6

b)

1,3,5

c)

2,4,6

d)

3,7,11

3.

for letter in "12345":

- if letter == 3:

-- break

- print(letter)

a)

1,2,4,5

b)

1,2

c)

1,2,3,4,5

d)

Error

4.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
5.
Tells the interpreter that the code which follows is a function
a)
const
b)
int
c)
def
d)
while
6.
If you want more than one option for your code, what do you use (after if)?
a)
elif
b)
else
c)
ifif
7.

What do while Loops do?

a)

A programming structure used to repeat actions without the player needing to write the same lines of code over and over.

b)

Data about or belonging to an object.

c)

Repeat a block of code while a certain condition is true.

d)

Repeat a block of code a certain number of times.

8.

choose the right variable name :

a)

var1 = 5

b)

vA_r = 5

c)

var-1 = 5

d)

1var = 5

e)

var 1 = 5

9.

x = {"apple", "banana", "cherry"}

what is the type of x ?

a)

tuple

b)

list

c)

set

d)

dictionary

10.

which one is the smallest unit ?

a)

module

b)

library

c)

package

11.

x = lambda a : a + 10

print( x(5) )

a)

50

b)

15

c)

51

d)

25

12.

Returns a random float number between 0 and 1

a)

random()

b)

shuffle()

c)

randint()

d)

sample()

13.

Opens a file for writing, creates the file if it does not exist

a)

"r"

b)

"a"

c)

"w"

d)

"x"

14.

What will be the output of: print ("3+57")

a)

3 + 57

b)

90

c)

60

d)

3+57

15.

What is the output of the following code?


x = 10

# x = 2 * x

print(x)

a)

20

b)

10 10

c)

210

d)

10