Page 60 - tp_Modula_v2.0
P. 60
On running the above program, you will get the following output:
Output
Enter first number: 5
Enter second number: 6
The sum is 11
Program 4: To find the product of two numbers using function.
Program4.py
File Edit Format Run Options Window Help
def prod(a,b):
multi=a*b;
return multi;
num1=int(input("Enter first number: "))
num2=int(input("Enter second number: "))
print("The product is", prod(num1, num2))
On running the above program, you will get the following output:
Output
Enter first number: 5
Enter second number: 4
The product is 20
Recap
A function is a block of organised and reusable code used to perform a single or related
action.
Python functions can be categorised into built-in functions and user-defined functions.
A function can be called anytime from other functions or from the command prompt after the
definition.
Exercise
A. Tick ( ) the correct option.
1. Which of the following is a block of code to perform a particular task?
a. Function b. Operator
c. Parameter d. Argument
58 Touchpad MODULAR (Version 2.0)

