Unit 3 Flashcards
What is the final result of the expression 4 + 5 * 3?
19
What is the final result of the expression 7 / 2 + 6?
9.5
Choose the print statement below that will cause an error. Assume that num has the value 6, and name has the value Isabella.
print(name + “: “ + num)
Which one of the statements below will cause an error?
ans = “hi” + 9
What does the following program print?
<type ‘str’>
Suppose you have a variable defined a = “4”. What is the variable type of a?
str
Choose the option that correctly prints out the variable(s).
language = “Python”
print(“I’m learning “ + language)
What kind of data does a float variable contain?
Numbers that can have decimal components
x = 3.4
y = 1
print(int(x))
print(x + y)
3
4.4
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 = int(input(“Enter a number: “))
What is the final result of the expression 2**3?
8
What is the character that in-line Python comments begin with?
#
What is the difference between a binary operator and a unary operator?
A binary operator needs two things, while a unary operator only needs one.
On which line of code will Python 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 2
In what order should these statements be executed in order to get input from the user and print out the result?
A) response = input(“Do you like cheese? “)
B) print(“You have chosen “ + confirm)
C) print(“You responded “ + response)
D) confirm = input(“Are you sure? “)
A, C, D, B