Class Test 3 - CS 12
Ans1. The advantages are:
- With function we can have code reuse
- The debugging process becomes easy
- Implementation of new features and removing existing features becomes easy
- Reduction of duplicate code
- Decomposing complex problems into simple pieces
- Information hiding
Ans:- Parameter:- The variables that are used in the function header during function declaration are called as parameters. Eg
def add(a, b, c): # Here a,b,c are the parameters
return a+b+c
Types of parameter are:
- Positional - add(a,b)
- Default - add(a=10, b=5)
- Variable length - add( *a)
add(10,45,23) # Here 10, 45, 23 are the Arguments (Positional)