Q9
1 markMCQSection A

What will be the output of the following code ?

``python

def f1(a,b=1):

print(a+b,end='-')

c=f1(1,2)

print(c,sep='*')

``

Functions
Functions - Default Arguments & Return Value

Options

(A)3-2
(B)3-2*
(C)3-None
(D)3*None-
Official Answer

Correct option: (C) 3-None


b takes the passed value 2 (overriding the default), so a+b=3 is printed with end='-' (no newline); since f1 has no return statement, c becomes None, and print(c, sep='*') simply prints None (sep is irrelevant with a single argument).

default parameterpositional argumentfunction return valueNoneprint end parameterprint sep parameterfunction call trace

Marking Scheme

  • 11 mark: correct option (C) 3-None selected; no partial credit awarded for MCQ.

Hint

Trace what f1() actually prints AND what it returns — a function with no return statement always returns None.

Quick Oral Answer

f1(1,2) prints '3-' because b is overridden to 2, but since f1 has no return statement it returns None, so print(c) displays 'None', giving overall output 3-None.

Analysis & Explanation

Tracing this program requires tracking both the printed output and the function's return value.


Why (C) is correct

  • The call f1(1,2) passes b=2 positionally, overriding the default b=1, so a+b = 1+2 = 3.
  • print(a+b, end='-') prints 3- without moving to a new line because end replaces the default \n.
  • f1 has no return statement, so Python implicitly returns None; therefore c = None.
  • print(c, sep='*') prints a single value, None; the sep argument only affects spacing between multiple arguments to print(), so it has no visible effect here.
  • Combining both print() calls gives the final displayed text 3-None.

Why the other options are wrong

  • (A) 3-2 wrongly assumes the function returns b (or the printed sum) instead of None.
  • (B) 3-2 incorrectly applies sep='' as if it inserts a * after a returned value of 2.
  • (D) 3*None- reverses the order of the two print statements and misapplies both end and sep.

Common Mistakes

  1. 1Assuming a function without an explicit return statement returns the last computed/printed value instead of None.
  2. 2Confusing the end parameter (used inside f1's print) with the sep parameter (used in the outer print), leading to wrong option selection.
  3. 3Forgetting that b=2 overrides the default value b=1 since it is passed positionally.

Interesting Facts

Every Python function implicitly returns None if it reaches the end of its body without an explicit return statement — this is a very common CBSE trap in output-based questions.

The end and sep keyword arguments of print() were introduced in Python 3 to give programmers explicit control over output formatting, replacing Python 2's print statement behaviour.

Spotted a mistake or something unclear?

Tell us — we fix reported answers fast.

Frequently Asked Questions

Why does the function return None even though it prints a value?

Printing and returning are different operations in Python. print() only displays output; a function's return value is whatever follows its return statement. Since f1 has no return statement, Python automatically returns None when the function finishes executing, regardless of what was printed inside it.

Does passing b=2 override the default parameter value b=1?

Yes. Default parameter values are only used when the caller does not supply a value for that argument. Since f1(1,2) supplies two positional arguments, 2 is assigned to b, completely overriding the default of 1 for this call.