Which choice creates a list of foods?*


foods = {"banana", "apple", "burrito"}

foods = ["banana", "apple", "burrito"]

foods = ("banana", "apple", "burrito")
None of the options

foods = ["banana", "apple", "burrito"]

If we have a list named colors, which of the following gives the length of the list?*


colors.length()

len(colors)

colors.len()

length(colors)

len(colors)

What is the output of the following code snippet?*

for num in range(5):
print(num)

1
2
3
4
5
0
1
2
3
4
5
1
2
3
4
0
1
2
3
4

0

1
2
3
4

Which keyword is used to create a function in Python?*


function

def

define

fun

def

Which keyword is used to send data out of a function?*

push
return
send
take

return

Which operator is used to multiply two numbers?*

%
/
*
&

*

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

fruits = [ "Apple", "Banana", "Orange" "Watermelon ]
for fruit from fruits
print(fruit))

fruits = [ "Apple", "Banana", "Orange", "Watermelon" ]

for fruit in fruits:
print(fruit)

Write a Python program which:*

- Creates a function called `add()` that takes two parameters: `num1` and `num2`.
- Return the sum of the numbers from the `add()` function.
- Prompts the user for number 1 and stores their response in a variable
- Don't forget to convert to the correct data type!
- Prompts the user for number 2 and stores their response in a variable
- Don't forget to convert to the correct data type!
- Uses the `add()` function to get the sum of the two numbers and stores it in a variable called `total`.
- Displays a message like: "[num1] + [num2] = [total]"
- You should replace each [] with the value of the variable it represents.

def add(num1, num2):

return num1 + num2

num1 = int(input("Enter number 1: "))
num2 = int(input("Enter number 2: "))
total = add(num1, num2)
print(f"{num1} + {num2} = {total}")

Write a Python program that:*

- Prompts a user for a number and stores the response in a variable called "user_number".
- Make sure to convert the user input to the correct data type.
- Multiplies the user's number by 10 and stores the result in a variable called "product".
- Displays: "[user_number] * 10 = [product]"
- You should replace [user_number] and [product] with the value of the appropriate variables.

user_number = int(input("Enter a number: "))

product = user_number * 10
print(f"{user_number} * 10 = {product}")

Write a Python program that:*

- Stores animal names in a list and then prints all of the values inside it using a `for` loop.
- You should have at least 4 animal names in your list.
- After the loop, display the total number of animals in the list.
- You should use a function to do this.
- The output should be something like: "There are __ animals in my list"
- Replace the __ with the number of animals in the list.

animals = ["lion", "elephant", "tiger", "giraffe"]

for animal in animals:
print(animal)

def count_animals(animal_list):
return len(animal_list)

total_animals = count_animals(animals)
print(f"There are {total_animals} animals in my list")