Unit 3 Flashcards
(20 cards)
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
What is the output of the following program? Assume the user enters “Florence”, then “Fernandez”.
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)
FlorenceFernandez
Which of the following statements is true about print statements?
I. In order to print a string literal, the string must be enclosed in quotes.
II. Each print statement will be printed on its own line.
III. Print statements will not let you print string and number characters in the same statement.
IV. Print statements are how you display text on the screen.
I, II, IV
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
Which of the following choices is NOT a Python variable type?
number
Choose the correct declaration of a float variable with the value 3.14.
pi = 3.14