3.1 - Defining Functions, Errors & Debugging
3.1 - Defining Functions, Errors & Debugging
Types of Errors
it is not executed.
Only the function name is created, which refers to the code block
inside the function.
When we call a function, the code block inside the function is actually
executed.
Function with no arguments
Such functions always do the same thing each time they are executed.
Output
1 # Function definition
+------------+
2 def display_greeting(): | Welcome! |
3 print("+------------+") +------------+
4 print("| Welcome! |") +------------+
| Welcome! |
5 print("+------------+")
+------------+
6
7 # Function call
8 display_greeting()
9
10 # Call it again
11 display_greeting()
Functions with arguments and return value