Question | Click to View Answer |
What does the following code print to the console? x = 32
print(x)
|
|
Assign the variable |
my_city = "New York"
print(my_city)
|
What does the following code print to the console? num1 = 10
num2 = 20
print(num1 + num2)
|
The variable |
What does the following code print to the console? s1 = "hot"
s2 = "dog"
print(s1 + s2)
|
"hotdog" is printed to the console. The variable |
What does the following code print to the console? print(f"I like the number {6 + 2}")
|
"I like the number 8" is printed to the console. This example uses string interpolation. When a string is preceded with a |
What does the following code print to the console? first_name = "television"
hobby = "homer"
tmp = first_name
first_name = hobby
hobby = tmp
print(f"{first_name} likes to watch {hobby}")
|
This exercise uses the |
What does the following code print to the console? first_name, last_name = "edward", "norton"
print(f"{first_name} {last_name} is an actor")
|
first_name = "edward"
last_name = "norton"
String interpolation is used to embed the two variables in a string. |
What does the following code print the console? y = 34
y = "pablo"
print(y)
|
|