Python: final assessment

This covers the whole course. Take it after the last module.

Final quiz

1. What does print(type(3 / 1)) show?
2. What is -7 // 2?
3. Which expression is True exactly when x is from 1 to 9, and False otherwise?
4. How many times does this print? for i in range(3): for j in range(i): print(j)
5. What is "Python"[::-1]?
6. x = [1, 2, 3]; y = x.copy(); y.append(4). What is len(x)?
7. Which of these can be a dictionary key?
8. What does len({1, 1, 2, 3, 3}) give?
9. What is the result of [i * 2 for i in [1, 2]] + [0]?
10. What does this function return for f(2)? def f(n): n * 2
11. What is the output? def f(a, b=[]): b.append(a); return b. print(f(1)); print(f(2))
12. try: int("x") except ValueError: print("a") finally: print("b"). What is printed?
13. A class has __init__(self, n). What does the call C(5) pass as self?
14. Which is true of a generator?
15. A stack holds [1, 2, 3], with 3 added last. What does the next pop give?
16. What is the complexity of a single loop over a list with a set lookup inside?
17. What is the best sorting choice in everyday Python code?
18. A recursive function has no base case. What will happen when it is called?

Practical assessment: Build a word statistics tool

Without using hints, write a program that reads several lines of text and prints a report on the words in it.

Final project

A budget tracker: Build a program that keeps track of income and spending from typed commands, and gives a clear report by category.

How it is evaluated

To complete this course