Chapter 03 - Functions
Chapter 03 - Functions
• Print Function
• Defining Function
• Calling Function
• Variable Scope
Disclaimer: The contents of these slides are taken from various publicly available resources such as books, talks
and lectures. They are being used for the purpose of classroom teaching and academic dissemination only. The
sources are acknowledged wherever possible.
• Combination methods which specify how the primitive operations can be combined with
one another to obtain a compound operation
• What is a function?
• Function Call
• This calls the actual function.
my_print(“Vireshwar”)
my_print(“Amit”)
my_print(“Shashank”)
num = int(input("Type a
• The returned value can be assigned to a
number... "))
variable.
print(num+1)
z = calc_func(3,5)
• A value-returning function can be called
by including it in an expression.
x = 5
g(x)
print(x)
• To use this library, we must import the math library in the program.
• Example:
• Function sqrt, which returns the square root of its argument, can be utilized after
importing the math library.