Python Function
Function is a group of instructions for a specific purpose.
By making function you can use the code as many times as you want
Syntax
# defining function def function_name(parameter_list): statement_1 statement_2 # Calling a function function_name(parameter_list)
Example
- def scanftree(a, b):
- if a>b
- print a
- else
- print b # defining function
- scanftree(5,6) # Calling a function
Output
6
- def scanftree(a, b):
- if a>b:
- print a
- else:
- print b # defining function
- scanftree(5,6) # Calling function
In the next chapter you are going to learn file-IO in python