WorksheetsUnit 3 Review
Total questions: 22
Worksheet time: 12mins
What does the following Python code display?
print("Hello")
print("World!")
Hello
World!
Hello World
What data type is the variable greeting?
greeting = "Hi there"
float
boolean
integer
string
What data type is the variable name?
name = input("Who are you? ")
string
float
integer
The type cannot be determined.
What is the result of this expression?
12 % 4
0
1
3
4
x = 4
y = 5
print(x + y)
x = 4
y = "hi"
print(x + y)
x = 4.5
y = 5.5
print(x + y)
x = 4
print(x+5)
Choose the option that correctly prints out the variable(s).
x = "codehs" print(int(x))
num = 8 print("num")
name = "Alyx"
age = 32 print(name + "is " + age)
language = "Python"
print("I'm learning " + language)
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?
num = str(input(“Enter a number: “))
num = number(input(“Enter a number: “))
num = input(“Enter a number: “)
num = int(input(“Enter a number: “))
What is the final result of the expression 4 + 5 * 3?
27
12
21
19
What is the final result of the expression 7 / 2 + 6?
0
9
9.5
0.875
Choose the print statement below that will cause an error if
num= 6
name = "Isabella"
print(name + ":" )
print(num)
print(name + " wants " + "num " + "candies")
print(name + ": " + str(num))
print(name + ": " + num)
Which one of the statements below will cause an error?
ans = “hi” * 8
ans = “hi” + 9
ans = “hi” + “hi” + “hi”
ans = (“a” * 4) + “b”
What does the following program print?
a = "hi"
b = 4
c = a * b
print(type(c))
<type 'str'>
<type 'int'>
<type 'float'>
The program crashes and doesn’t print anything.
What kind of data does a float variable contain?
Whole numbers
Words
Numbers that can have decimal components
A float is not a Python variable type
What does the following code print?
x = 3.4
y = 1
print(int(x))
print(x + y)
3.4
4.4
3
4.4
3
4
The code causes an error
What is the final result of the expression 2**3?
6
8
2
That is not a valid Python expression.
What is the character that in-line Python comments begin with?
#
%
-
"
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?
user_age
uSeRaGe
user!age!
1user_age
Which of the following choices is NOT a Python variable type?
str
int
float
number
Which is the correct way to declare a float variable with the value 3.14?
pi = “3.14”
pi = int(3.14)
pi = 3.14
float pi = 3.14
What data type is the variable age?
age = 17
string
float
integer
The type cannot be determined.
What data type is the variable price?
price = 5.99
string
float
integer
The type cannot be determined.
