#1 What is the output of the below program?

What is the output of the below program?

def sum(a, b = 2):
    print(a+b)
    
sum(3,3)

Explanation: 
Parameters can be assigned in the function definition. But when a function is called and parameter is passed from calling function, the value passed takes precedence. So, the output of this program is 6 and not 5 as b value is 3 and not 2. The value of b is overridden.

Post a Comment

0 Comments