1/10
Landon Van Berkuk, Based on quizzes 67 8
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
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.