English

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='*') - Computer Science (Python)

Advertisements
Advertisements

Question

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='*')

Options

  • 3−2

  • 3−2*

  • 3−None

  • 3*None

MCQ
Advertisements

Solution

3−None

Explanation:

  • Function Call: When f1(1, 2) It is called, it prints the sum 1+2 (which is 3) and uses the end='-' parameter, resulting in the output 3-.
  • Return Value: The function f1 does not have a return statement. In Python, if a function doesn’t explicitly return a value, it returns None. Therefore, the variable c is assigned the value None.
  • Final Print: The statement print(c, sep='*') then prints the value of c, which is None.
  • Combined Output: Joining the two print actions together gives 3-None.
shaalaa.com
  Is there an error in this question or solution?
2025-2026 (March) Set 4
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×