Topic: Where to put functions in a program CMPT 120 Topic: Where to put functions in a program
Where to put functions in our Python program Header comment block + import statement(s) # Header Comment Block # Function 1 … Function definitions # Function n # Main part of my program The main part of my program
Function call –> situation 1 Python program Header comment block + import statement(s) # Header Comment Block # Function Function definition # Main part of my program Function is called The main part of my program
Function call –> situation 2 Python program Header comment block + import statement(s) # Header Comment Block # Function 1 Function definitions # Function 2 # Main part of my program Function 1 is called The main part of my program Function 2 is called
Function call –> situation 3 Python program Header comment block + import statement(s) # Header Comment Block # Function 1 Function definitions # Function 2 Function 1 is called # Main part of my program The main part of my program Function 2 is called
Function call -> Would this situation work? Python program # Header Comment Block Header comment block + import statement(s) # Function 1 Function definition # Main part of my program Function 1 is called The main part of my program Function 2 is called # Function 2 Function definition
Function call –> Would this situation work? Python program Header comment block + import statement(s) # Header Comment Block # Function 1 Function 2 is called Function definitions # Function 2 # Main part of my program The main part of my program Function 1 is called
Where to put functions in our Python program – Not a good idea! Header comment block + import statement(s) # Header Comment Block # Main part of my program The main part of my program # Function 1 Function definitions # Function 2