Which code sample correctly uses string interpolation to insert the variable `favorite_food` into a string?*
f"My favorite food is {favorite_food}"
"My favorite food is {favorite_food}"
f"My favorite food is [favorite_food]"
"My favorite food is (favorite_food)"
The correct code sample that uses string interpolation to insert the variable `favorite_food` into a string is:
```python
f"My favorite food is {favorite_food}"
```
Which example imports the `randint()` function from the `random` module?*
from random import randint()
from randint import random
from random import randint
from randint() import random
The correct example that imports the `randint()` function from the `random` module is:
```python
from random import randint
```
Which data structure stores items in key/value pairs?*
dict
list
str
bool
The data structure that stores items in key/value pairs is a dictionary (dict).
Which value represents a `bool`?*
0
{}
True
[]
The value that represents a bool is `True`.
40. Would the following code print something?*
num = 5
if num == 0 or num == 1:
print("The number is 0 or 1")
Yes, it prints the following text: "The number is 0 or 1"
No, there's an error so an error message would be displayed
No, there is an error in the code. The code is missing an indentation for the `print()` statement within the `if` block. To fix the error, the code should be indented correctly, like this:
```python
num = 5
if num == 0 or num == 1:
print("The number is 0 or 1")
```
Without the correct indentation, an IndentationError would be raised.
Write a Python program that:*
- Creates an empty list called `favorite_foods`.
- Creates a loop that runs three times.
- In the loop:
- Prompt the user for their favorite food
- Add the user's response to the `favorite_foods` list
- After the loop, use another loop to display the user's favorite foods
in this form:
Your favorite foods are:
- tacos
- burritos
- nachos