Junior Python interview: exceptions and try/except
Egor is taking a mock interview for the role of Junior Python Developer. In this episode, we break down exceptions in Python: why we need `try`/`except`, how an error differs from an exception, how `else` and `finally` work, where to handle exceptions correctly, and what happens if the code crashes inside a handler.
The result is an honest analysis of Egor’s first interview: plenty of doubts, unexpected questions, hands-on coding exercises and detailed feedback on how to boost your fundamental knowledge and experience.
Timestamps:
00:00 — Start
00:33 — Introductions and interview format
03:35 — What is an exception in Python
06:03 — Why do we need try/except
11:03 — What code to place inside the try block
20:23 — Types of exceptions: ValueError, TypeError, KeyError and others
22:53 — Custom exceptions and raise
31:42 — How try and except blocks work
36:00 — The order in which exceptions are handled
40:18 — else and finally: why are they needed
41:27 — An error within an except block
44:10 — Where is the best place to handle an exception: within a function or outside it
45:40 — Practical exercise with code
53:20 — Candidate’s self-assessment
55:02 — Feedback on the interview