ICT Lecture 26 28 (Functions)
ICT Lecture 26 28 (Functions)
2
Functions can be used to define
Introduction reusable code to organize and
simplify code.
3
A function definition consists of
Defining a the function’s name, parameters,
Function and body.
4
A function definition consists of
Defining a the function’s name, parameters,
Function and body.
6
Calling a function executes
Calling a Function the code in the function.
10
12
The scope of a variable is the
The Scope of part of the program where the
Variables variable can be referenced.
13
The scope of a variable is the
The Scope of part of the program where the
Variables variable can be referenced.
15
Common Python Functions
16
Common Python Functions
''' Simple Python builtin functions
'''
num1, num2, num3 = -3, 16, 7.2
absNum = abs(num1) # Returns the absolute value
print ("Absolute value = ",absNum)
17
18
Mathematical Functions
19