wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python 2

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What output does this code produce?

a)

5

5

5

5

5

b)

5

c)

0

1

2

3

4

5

d)

0

1

2

3

4

2.

What output does this code produce?

a)

HelloGuyHelloGuyHelloGuy

b)

HelloGuy

c)

HelloHelloHelloGuyGuyGuy

d)

HelloGuy

HelloGuy

HelloGuy

3.

What output does this code produce?

a)

High

b)

Low

c)

Perfect

d)

500

4.

What would you use to repeat a block of code an indeterminate number of times . This means you don't know how many times it will repeat.

a)

for loop

b)

while loop

c)

repeat loop

d)

if statement

5.

Which is a syntactically correct function definition header?

a)

print_again(s)

b)

print(s)

c)

def print_again(s):

d)

print_again(string):

6.

Which is a valid assignment statement?

a)

"x" = 5 * 7

b)

5 = print_times

c)

print_times = 5

d)

print = 5

7.

What does this function do?

a)

Prints the value of the greater of the two parameters

b)

Prints the value of the sum of the two parameters

c)

Returns the value of the greater of the two parameters

d)

Compares two integers and chooses the smaller

8.

For this function, what would be the output of this call?

print(greater_value(5, 100))

a)

100

b)

5

c)

105

d)

500

9.

For this function, which code would generate a Python error?

a)

_var_name = greater_value(7.5, 9)

b)

greater_value("7", 9)

c)

greater_value(7, 9)

d)

x = greater_value(7, 9)

10.

Which code would definitely generate an error?

a)

x = input("Enter a number")

print(x + 7)

b)

x = input("Enter a number")

print(x*2)

c)

x = input("Enter a number")

print(x + "7")

d)

x = int(input("Enter a number"))

print(x + 7)