Lecture 7 — Functions

Overview

  • In todays Lecture we discuss functions.

  • A function in Python is a ‘chunk of code’ that is written once and can be used again and again.

  • Re-usability plays a significant role in debugging and breaking down complex problems into simpler

and smaller steps.

What is a function?

A body of code that takes an input, does some computation and returns a value.

Some built in functions include len, print, int, float etc.

What is Module?

Embedding two or more functions together creates a module.

A module has multiple ‘related’ functions. The module needs to

be imported before use. Once imported its functions can be called

and used.