wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Review 2023-01-12

Total questions: 10

Worksheet time: 12mins

Name
Class
Date
1.

What does this function do?

a)

Returns the product of its parameters

b)

Returns the sum of its parameters

c)

Returns the largest of its parameters

d)

Returns the smallest of its parameters

2.

What will this code snippet print?

a)

cow

b)

sheep

c)

pig

d)

ox

3.

You want to write code to aske the user to enter his or her favorite food and then print "good" if the response is "fries" and "bad" if it isn't. Reorder the statements below to accomplish this.

a)
b)
c)
d)
e)
1)
2)
3)
4)
5)
4.

How would you write a for loop to repeat 15 times using a counter variable called count?

for ​ (a)   ​ (b)   ​ (c)   ​ (d)  

Choose from the below words
count
in
range(15)
:
5.

You want to create a conditional to check whether a variable called n is positive. How would you do this?

​ (a)   n ​ (b)   ​ (c)   ​ (d)  

Choose from the below words
if
>
0
:
<
<=
>=
==
!=
for
6.

A ​ (a)   loop repeats a specified number of times. A ​ (b)   loop repeats as long as a condition is met.

Choose from the below words
for
while
conditional
list
block
if
variable
function
recursive
iterative
7.

Match each description with the code snippet that is an example of that description.

a)
1.

conditional

b)
2.

function

c)
3.

for loop

d)
4.

while loop

e)
5.

list

8.

A ​ (a)   is a data structure that stores multiple pieces of data in a single variable. The values in a list are called ​ (b)   and you can reference specific elements in a list by using a(n) ​ (c)   which is an integer that specifies the position of the data in the list and which starts counting at ​ (d)   .

Choose from the below words
list
elements
index
0
1
queue
stack
hash
address
-1
9.
Question Image

Given this code snippet, match the following python expressions with their values.

a)

-2

1.

stuff[3]

b)

0

2.

stuff[2]

c)

4

3.

stuff[7]

d)

-6

4.

stuff[6]

e)

13

5.

stuff[1]

10.

What values for a and b will cause this code snippet to print "aardvark"?

a)

a = 12, b = 4

b)

a = 13, b = 3

c)

a = 34, b = -6

d)

a = 20, b = 0