Skip to content
Question 40 of 97

Q.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='') (A) 3-2 (B) 3-2 (C) 3-None (D) 3*None-

Uttar Pradesh UpmspCBSE Class XII Board 2026MCQ· 1mImportance★★★★★
41% · 40/97 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

The function f1 prints 3- (since 1+2=3 with end='-'), then returns None implicitly, which the outer print displays — giving 3-None, option (C).

When a Python function has no explicit return, it returns None. This question tests the difference between what a function prints and what it returns, and how print handles None and its keyword arguments.

The function f1(a, b=1) computes a+b and prints it with end='-' instead of a newline. There is no return, so calling f1(1,2) prints the sum and evaluates to None, which is then assigned to c.

Trace of the execution:

  1. Call f1(1, 2) — inside, a=1 and b=2, so a+b is 3.

  2. print(a+b, end='-') — outputs 3 and, instead of a newline, ends with -. So far the console shows:

    3-
    
  3. Function returns None — with no return statement, f1 returns None, so c = f1(1,2) stores None in c. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.