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

Here is a Python program that accomplishes the specified tasks:

```python
favorite_foods = []

# Prompt user for favorite foods and add to the list
for _ in range(3):
food = input("Enter your favorite food: ")
favorite_foods.append(food)

# Display the user's favorite foods
print("Your favorite foods are:")
for food in favorite_foods:
print("- " + food)
```

When you run this program, it will prompt the user three times to enter their favorite food. After receiving the inputs, it will display the user's favorite foods in the desired format.

Write a Python program which:*

- Creates a variable to hold an `admin_username` with whatever username you wish.
- Creates a variable to hold an `admin_password` with whatever password you wish.
- Prompts the user for a `username`.
- Prompts the user for a `password`.
- Checks if the `username` and `password` provided by the user are the same as the `admin_username` and `admin_password`.
- If they are the same, display: "Welcome admin!"
- If they are not the same, display: "Sorry, those credentials are incorrect!"

Here is a Python program that fulfills the given requirements:

```python
admin_username = "admin"
admin_password = "password"

username = input("Enter username: ")
password = input("Enter password: ")

if username == admin_username and password == admin_password:
print("Welcome admin!")
else:
print("Sorry, those credentials are incorrect!")
```

When you run this program, it prompts the user for a username and a password. Then, it checks if the provided username and password match the admin's username and password. If they match, it displays "Welcome admin!". If they don't match, it displays "Sorry, those credentials are incorrect!". You can modify the `admin_username` and `admin_password` variables as per your preference.

Find & fix syntax error(s) in the following code:*

meaning_of_life == input(What is the meaning of life? )
if meaning_of_life = programming
print("That's correct!)
else:
print("That is incorrect, try again!")

Here is the corrected code with the syntax errors addressed:

```python
meaning_of_life = input("What is the meaning of life? ")

if meaning_of_life == "programming":
print("That's correct!")
else:
print("That is incorrect, try again!")
```

In the original code:
- The variable assignment `meaning_of_life == input(What is the meaning of life?)` should use a single equal sign `=` instead of a double equal sign `==`.
- The `input()` function should have the prompt message inside quotes: `input("What is the meaning of life? ")`.
- The condition `if meaning_of_life = programming` should use a double equal sign `==` for equality comparison.
- The `print("That's correct!)` statement is missing a closing quotation mark for the string.
- The `else` clause should have an indented block for the `print()` statement.

The corrected code fixes these errors and runs without syntax issues.

Write a Python program that:*

- Creates a list of `wizards` with these values:
- "Daniel", "Sam", "Sahib", "Ivann"
- Prompts the user to guess a wizard's name
- Store their response in a variable called `wizard_name`
- If the user guesses a wizard in your `wizards` list, display: "That's correct! [wizard_name] is a wizard!
- Replace `wizard_name` with the name the user guessed
- If the user didn't guess a wizard in your `wizards` list, display: "Sorry, [wizard_name] is not a wizard."
- Replace `wizard_name` with the name the user guessed

Here is a Python program that accomplishes the given tasks:

```python
wizards = ["Daniel", "Sam", "Sahib", "Ivann"]

wizard_name = input("Guess a wizard's name: ")

if wizard_name in wizards:
print(f"That's correct! {wizard_name} is a wizard!")
else:
print(f"Sorry, {wizard_name} is not a wizard.")
```

When you run this program, it creates a list of wizards. It then prompts the user to guess a wizard's name and stores their response in the `wizard_name` variable. After that, it checks if the user's guess matches any name in the `wizards` list. If it does, it displays "That's correct! [wizard_name] is a wizard!" where `wizard_name` is replaced with the name guessed by the user. If the user didn't guess a wizard in the `wizards` list, it displays "Sorry, [wizard_name] is not a wizard." where `wizard_name` is replaced with the name guessed by the user.