quiz 2 Flashcards
What is the output of the print() statement after the following code:
m = 2
for n in range(3, 15, 5):
n += m + 2
print(n)
17
After running the following Python code, what will the variable x_list contain?
x_list = []
for n in range(4):
x_list.append(n**2)
[0, 1, 4, 9]
What is the output printed to the console after executing the following statements?
x = [“Fall”]
y = [“Spring”, “Summer”, “Winter”]
z = x + y
print(z)
[ ‘Fall’, ‘Spring’, ‘Summer’, ‘Winter’]
What is the output printed to the console after the following statements?
x = [[1], 2]
y = x.copy()
y[0][0] = 100
print(x, y)
[[100], 2] [[100], 2]
What is the result of running the following statements?
x = {“salmon”: “fish”, “orca”: “whale”}
y = x[“fish”]
print(y)
Code generates KeyError
What is the output of the following?
for x in range(10, 20, 2):
print(x, end=” “)
10 12 14 16 18
What is the output after the following statements?
x = 100
def new_function():
print(x)
new_function()
100
f we run the following Python code:
m = [(1,2), (3,4)]
for x, y in m:
print(x, y, end=” “)
What will be the output printed to the console?
1 2 3 4
What is output after the following statement?
x = 1
y = 2
z = x == y
print(z)
False
What is the data type of x?
x = (“Boston University”)
string