Level 3 exam — harder

Exam — fresh questions

3.1 · Recall

1. A module and a package are…

Module = .py file; package = folder — both are imported instead of copied.
3.1 · Application

2. Nabil reuses frequence from stats.py without replaying the demo. He writes…

Explicit import + demo under __main__: imported = functions only.
3.1 · Arbitration

3. A colleague suggests from utils import * “to go fast”. Correct call?

The star pollutes the namespace and hides origins — explicit and absolute, no exceptions.
3.2 · Recall

4. A venv's job is first to…

One Python + packages per project: two incompatible versions coexist undisturbed.
3.2 · Application

5. Nabil isolates his sales analysis then pins the contract. He writes…

Create, activate, install, pin: versioned requirements makes the project portable.
3.2 · Arbitration

6. Should the .venv folder be versioned? Correct call?

.venv = bulky and machine-specific; requirements alone rebuilds.
3.3 · Application

7. Nabil sorts his sales by amount in one throwaway line. He writes…

Throwaway lambda in key: one-line criterion, def as soon as it gets a name.
3.3 · Application

8. Nabil reads a multi-GB export without saturating RAM. He writes…

Yield produces on demand: constant memory, even over GBs.
3.3 · Recall

9. A decorator with functools.wraps is for…

It receives the function, returns a wrapper (timer, log) — wraps preserves identity.
3.4 · Application

10. Nabil tests his VAT: nominal and negative price. He writes…

Minimal trio: nominal + edge + error — pytest -q after each change.
3.4 · Application

11. Nabil documents his average function without changing execution. He writes…

Hints = readable intent, ignored at runtime, checkable by mypy.
3.4 · Arbitration

12. Before sending reports, Nabil only tested the nominal case. Correct call?

Bugs live at the edges: with no edges or errors, regressions go unnoticed.
What's next?
Back to the guideGuide contents