Wednesday 11/29¶
Quiz Prep – Nested Structures¶
- Open up the scavenger hunt activity
- Complete the JSON version of exercise 1 for the Art JSON file.
Quiz Prep – Recursion¶
Trace the following Python program on paper. Draw each activation record as a box containing the appropriate arguments.
def count_threes(num):
return count_digit(num, 3)
def count_digit(num, digit):
if num == 0:
return 0
else:
last = num % 10
rest = num // 10
if last == digit:
return 1 + count_digit(rest, digit)
else:
return count_digit(rest, digit)
if __name__ == "__main__":
count = count_threes(4323)
- How many TOTAL function calls occur when this program is executed,
including the original call to
count_threes
? - Which line in the code checks for the base case?
Quiz Instructions¶
- Log into the desktop as
student
with no password. - Log into Canvas.
- Wait until the instructor says to start before accessing Part 1.
- The quiz can be found in the "Modules" section of Canvas.
- The entire quiz has a 25 minute time limit.
- Part 1 (Conceptual):
- You may not use Thonny (or any other resources) for Part 1.
- Part 2 (Coding):
- You have unlimited submissions.
- You do NOT need to provide docstrings.
- The autograder will NOT check for PEP8 violations (though you should still use good style.)
- You must use Thonny as your editor.
- You may not access any external web pages or other resources.