All courses
· beginner

Functions and Error Handling

Package work so it can be reused, tested and trusted. Arguments, return values, scope, and handling failure deliberately instead of letting a script die at line one hundred.

Pathaxis · Original content

Written in house, from the work rather than from a syllabus. Every example is one we would use ourselves, and every exercise is checked against the same engine that grades your answer.

69 min 5 lessons 18 quiz questions 6 exercisesStart course

What you’ll learn

  • Write functions with clear inputs and one clear output
  • Use positional, keyword and default arguments correctly
  • Explain scope and why a function cannot see your loop variable
  • Catch only the exceptions you can handle, and raise your own
  • Use a context manager so cleanup always happens
  • Split code across modules and import it

Before you start

  • · Python Foundations and Data Structures in Python

Syllabus

01

Writing functions

Arguments, returns and scope.

02

When things go wrong

Exceptions, and handling them where it helps.

03

Organising code

Modules, imports and what runs when.