Advertisements
Advertisements
प्रश्न
What will be the output of the following code?
def f1(a,b=1):
print(a+b,end='-')
c=f1(1,2)
print(c,sep='*')
विकल्प
3−2
3−2*
3−None
3*None
MCQ
Advertisements
उत्तर
3−None
Explanation:
- Function Call: When
f1(1, 2)It is called, it prints the sum1+2(which is 3) and uses theend='-'parameter, resulting in the output3-. - Return Value: The function
f1does not have areturnstatement. In Python, if a function doesn’t explicitly return a value, it returnsNone. Therefore, the variablecis assigned the valueNone. - Final Print: The statement
print(c, sep='*')then prints the value ofc, which isNone. - Combined Output: Joining the two print actions together gives
3-None.
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
