NEW
Font size
WorksheetsPython Basics (CodeHS)
Total questions: 20
Worksheet time: 12mins
What is the final result of the following expression?
5 + 4 * 3 - 1
What is the final result of the following expression?
(5 - 3) * 2 - 4
What is the final result of the following expression?
(3 + (8 / 2 - 2)) ** 2
Based on the following code, what gets printed to the screen?
greeting = 7
name = "Bob"
greeting = "Hello"
print(type(greeting))
Based on the following code, what gets printed to the screen?
greeting = 7
name = "Bob"
greeting = "Hello"
print(greeting)
Suppose you have a variable defined as num = "6". What is the variable type of num?
boolean
integer
string
float
Suppose you have variable x = 4 and y = 2. What will get printed to the screen when this is executed?
print(x / y)
error
0.5
2
2.0
Which choice below correctly prints out the value of the variable?
city = "Searcy"
print(type(city))
print("city")
print("Searcy")
print(city)
What kind of data does an integer contain?
Whole numbers
Letters, special characters, numbers, or words
Numbers with decimal components
True or False
What kind of data does an string contain?
Whole numbers
Letters, special characters, numbers, or words
Numbers with decimal components
True or False
What does the following code print?
x = 3.5
y = 2
print(int(x))
print(x + y)
4
5.5
3
5.5
3
5
4
5
What is the best way to get a number from the user to use in a calculation?
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 3**2?
3
6
1.5
9
What is the appropriate symbol(s) used for in-line comments in Python?
%
#
"""
"""
//
What is the appropriate symbol(s) used for modulus in Python?
%
#
"""
"""
//
Examine the code below. On which line of code will there be an error?
weight = input("How much do you weigh? ")
oz_water = weight / 2
print("You should drink " + str(oz_water))
print("ounces of water every day if you weigh " + weight)
Line 1
Line 2
Line 3
Line 4
Why does line 2 result in an error?
weight = input("How much do you weigh? ")
oz_water = weight / 2
weight is a string and cannot be divided
weight is a boolean and cannot be divided
Line 1 does not get input from the user correctly
There is no error
What is the output of the following program? Assume the user enters "John", then "Smith".
first_name = input("What is your first name? ")
last_name = input("What is your last name? ")
whole_name = first_name + last_name
print(whole_name)
John Smith
JohnSmith
Smith John
John
Smith
