1/10
Landon Van Berkuk, Based on quizzes 67 8
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
Interactive Loop
Will stop looping unless "told" to continue
Sentinel Loop
Will keep looping unless "told" to stop
Pre-Test Loop
May not loop at all, depending on initial conditions
Definite Loop
Knows exactly how many times it will iterate ahead of time
Indefinite Loop
Doesn't know how many times it will iterate
True or False: Tuples are ordered, but Dictionaries are unordered.
True
What will the following code print out?
x = 10
for i in range(1,4):
x = x * i
for k in range(1,4):
x = x - k
print(x)
0
Given the following list of lists, which statement will access the 'X'?
table = [['O', 'O', 'O'],
['X', 'O', 'O'],
['O', 'O', 'O']]
table[1][0]
Consider the following code snippet. How many times will statement #1 be run?
x = 400
for i in range(5):
for k in range(6):
# Statement #1
x = x - (i*k)
# Statement #2
x = x * i
5×6=30
Consider the following code snippet. How many times will statement #2 be run?
x = 400
for i in range(5):
for k in range(6):
# Statement #1
x = x - (i*k)
# Statement #2
x = x * i
5
What does the following code snippet print out?
def recur(a, b):
if a == 0:
return b
elif b == 0:
return a
else:
return 1 + recur(a-1, b-1)
print(recur(4,6))
2+1+1+1+1=6.