What is def ( ) for in if else statements?

I saw that at the beginning of if statements, if else/elif statements there is def ___ ( ):
For example def using_control_once():
def greater_less_equal_5(answer):

Could someone explain what the def is for please?

This is an example of an exercise that has it https://www.codecademy.com/courses/learn-python/lessons/conditionals--control-flow/exercises/i-got--problems-but-a-switch-aint-one

def is short for “define” and is used in function definition in Python. So, in your example, you use the def keyword to start the function definition which has the name greater_less_equal_5 that takes answer as a parameter inside the parenthesis. The colon denotes the end of the function definition. I hope my explanation was clear.

2 Likes