Extend it:

Find and fix common errors in your code
Python runtime errors: Find and fix common errors in your code

Now that you’re aware of what runtime errors are and how to use try and except to let your program cope with them without crashing, it’d be a good idea to go back to some of your previous python projects to make them more robust.


  1. Adapt this program which calculates some stats about how much you use your smartphone to make it more robust. 

    First, test the code to see what input you can put in which would make it crash. Then use try and except to give the user a friendly error message instead of crashing.

  2. Adapt this program which calculates how old you’ll be at any point in the future to make it more robust

    There’s some syntax errors to debug first before you can think about dealing with the runtime errors with try and except

  3. Write a take-away meal price splitter program which asks you how much a meal costs and how many people are going to share it. It will then work out how much each person has to pay.

    Remember that converting user input to a number is a time when you need to be careful about runtime errors. Use try and except to make your code more robust

Page 1: Intro

Page 2: The theory: learn what you need to know as fast as possible.

Page 3: Try it: try out and adapt some working python code snippets.

Page 4: Debug it: Learn how to find and fix common mistakes.

Page 5: Extend it: Choose a project idea to use your newfound python skills.