Lesson 6/6 · Graduation exam preparationNot startedhigh School~60 min
Exceptions (try – except)
A program that does not crash on bad input: asking again for a number, division by zero and several `except` branches.
After this lesson you'll be able to:
- Catch a `ValueError` when turning text into a number
- Tell several kinds of errors apart with `except` branches
- Understand the order of `try`, `except`, `else` and `finally`
Theory (PDF)
The theory for this lesson is being prepared.
Examples to try
Your code runs only in this browser, in an isolated environment with no access to the internet or your account.
Examples for this lesson are being prepared.
Exercises
Start the exercises- Write a programA numeric passwordBasic10 XP
- Small projectGuess a number from 1 to 50Elementary20 XP
- Write a programA bounded Fibonacci sequenceElementary20 XP
- Write a programIs the number divisible?Elementary20 XP
- Write a programA safe averageElementaryOptional20 XP
- Predict the outputtry, except, else, finallyIntermediateOptional30 XP