Python: Hello world Flashcards

1
Q

What is the output of the following code?

cool_number = 12 + 30
cool_number * 5
print(cool_number)

A

42

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What character begins a comment in Python?

A

#

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What number is saved to exponented_variable in the following expression?

exponented_variable = 2 ** 4

A

16

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How does one define a multi-line string in Python?

A

”””
Like
This
“””

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the value of modulo_variable in the following expression?

modulo_variable = 14 % 4

A

2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

A

cool_variable_3

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which function outputs text to the terminal?

A

print()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What happens when running the following code?

message = What a cool message!
print(message)

A

Python throws a SyntaxError because the string is not surrounded by quotes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the value of total_cost that gets printed?

total_cost = 5
total_cost += 10
print(total_cost)

A

15

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the difference between a float and an int?

A

A float represents decimal quantities. An int represents whole numbers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you combine two strings?

A

string1 + string2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Python syntax for creating a variable and assigning the number 10 to it?

= or ==?

A

variable_name = 10

How well did you know this?
1
Not at all
2
3
4
5
Perfectly