Firstly there are 2 keywords you need to know here.

  1. procedures
  2. functions

The next lesson in the roadmap will look at functions. This lesson looks at procedures.

<aside> 💡 Think of a procedure as a pre-set sequence of code that can be carried out when needed.

<aside> 🎮 You use them all the time when using a mobile phone or playing a game on a console. eg. when you click on the move button to move left or right

Untitled

</aside>

</aside>

The anatomy of a procedure/function

Look at this example of a simple procedure below in Python.

def greeting():
		print("hello")

Untitled

To call (or in other words to use) a function, type the name with parenthesis. In the example below greeting one is called. Try to change the code on line 7 to call greeting2 instead.

https://replit.com/@bitFez/functionexample1

Arguments

Sometimes we need to give a procedure or a function some data so that it can make use of it. An easy example of how this would work is a number machine

in the example below, the number machine takes a number (an argument) and outputs a result.

Untitled

def numberMachine(givenNumber):
		calculation = givenNumber * 10 / 2
		print(calculation)

Untitled

https://youtube.com/shorts/RHOixwZ-YQ8?si=Rgh01l4aRI2WdzBZ