wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Unit 3 Review

Total questions: 22

Worksheet time: 12mins

Name
Class
Date
1.

What does the following Python code display?

print("Hello")

print("World!")

a)

Hello

World!

b)

Hello World

2.

What data type is the variable greeting?

greeting = "Hi there"

a)

float

b)

boolean

c)

integer

d)

string

3.

What data type is the variable name?

name = input("Who are you? ")

a)

string

b)

float

c)

integer

d)

The type cannot be determined.

4.

What is the result of this expression?

12 % 4

a)

0

b)

1

c)

3

d)

4

5.
Which of the following Python programs will not run?
a)

x = 4

y = 5

print(x + y)

b)

x = 4

y = "hi"

print(x + y)

c)

x = 4.5

y = 5.5

print(x + y)

d)

x = 4

print(x+5)

6.
Which of the following best describes the main purpose of comments?
a)
Comments create better spacing in programs.
b)
Comments describe your program so other people can read it more easily.
c)
Comments warn the people running the program about potential problems with the program.
7.

Choose the option that correctly prints out the variable(s).

a)

x = "codehs" print(int(x))

b)

num = 8 print("num")

c)

name = "Alyx"

age = 32 print(name + "is " + age)

d)

language = "Python"

print("I'm learning " + language)

8.

Which of the following options is the best way to get a number from the user that you plan to use in a mathematical equation?

a)

num = str(input(“Enter a number: “))

b)

num = number(input(“Enter a number: “))

c)

num = input(“Enter a number: “)

d)

num = int(input(“Enter a number: “))

9.

What is the final result of the expression 4 + 5 * 3?

a)

27

b)

12

c)

21

d)

19

10.

What is the final result of the expression 7 / 2 + 6?

a)

0

b)

9

c)

9.5

d)

0.875

11.

Choose the print statement below that will cause an error if

num= 6

name = "Isabella"

a)

print(name + ":" )

print(num)

b)

print(name + " wants " + "num " + "candies")

c)

print(name + ": " + str(num))

d)

print(name + ": " + num)

12.

Which one of the statements below will cause an error?

a)

ans = “hi” * 8

b)

ans = “hi” + 9

c)

ans = “hi” + “hi” + “hi”

d)

ans = (“a” * 4) + “b”

13.

What does the following program print?

a = "hi"

b = 4

c = a * b


print(type(c))

a)

<type 'str'>

b)

<type 'int'>

c)

<type 'float'>

d)

The program crashes and doesn’t print anything.

14.

What kind of data does a float variable contain?

a)

Whole numbers

b)

Words

c)

Numbers that can have decimal components

d)

A float is not a Python variable type

15.

What does the following code print?

x = 3.4

y = 1

print(int(x))

print(x + y)

a)

3.4

4.4

b)

3

4.4

c)

3

4

d)

The code causes an error

16.

What is the final result of the expression 2**3?

a)

6

b)

8

c)

2

d)

That is not a valid Python expression.

17.

What is the character that in-line Python comments begin with?

a)

#

b)

%

c)

-

d)

"

18.

Which of the following choices is a properly formed Python variable name, meaning it is both legal in the Python language and considered good style?

a)

user_age

b)

uSeRaGe

c)

user!age!

d)

1user_age

19.

Which of the following choices is NOT a Python variable type?

a)

str

b)

int

c)

float

d)

number

20.

Which is the correct way to declare a float variable with the value 3.14?

a)

pi = “3.14”

b)

pi = int(3.14)

c)

pi = 3.14

d)

float pi = 3.14

21.

What data type is the variable age?

age = 17

a)

string

b)

float

c)

integer

d)

The type cannot be determined.

22.

What data type is the variable price?

price = 5.99

a)

string

b)

float

c)

integer

d)

The type cannot be determined.