Python: Hello world Flashcards
What is the output of the following code?
cool_number = 12 + 30
cool_number * 5
print(cool_number)
42
What character begins a comment in Python?
#
What number is saved to exponented_variable in the following expression?
exponented_variable = 2 ** 4
16
How does one define a multi-line string in Python?
”””
Like
This
“””
What is the value of modulo_variable in the following expression?
modulo_variable = 14 % 4
2
Which of the following defined variables is a string?
cool_variable_1 = 23.18
cool_variable_2 = 9
cool_variable_3 = “Important Message!”
cool_variable_4 = 14 ** 3
cool_variable_3
Which function outputs text to the terminal?
print()
What happens when running the following code?
message = What a cool message!
print(message)
Python throws a SyntaxError because the string is not surrounded by quotes.
What is the value of total_cost that gets printed?
total_cost = 5
total_cost += 10
print(total_cost)
15
What is the difference between a float and an int?
A float represents decimal quantities. An int represents whole numbers.
How do you combine two strings?
string1 + string2
What is Python syntax for creating a variable and assigning the number 10 to it?
= or ==?
variable_name = 10