Oliver Irwin
16th March 2023
You have seen that writing code can be a tedious task
(especially if you have to repeat the same instructions in different contexts)
We need to find a way to simplify writing code
Functions are used to set aside instructions that should be used at different parts of the program
To def-ine a function, we use the def keyword
A Python function is an element that has:
and optionnally:
You can use functions to create new values or transform existing ones
To do this, you can use the
return keyword
Careful! The return
keyword stops the execution of the function
Most times, when you create or use a function that returns a value, you want to store it in a variable
You saw this with the input
function!