Question:medium

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

Show Hint

f1 prints 3- and returns None, and sep has no effect when print has a single argument.
Updated On: Oct 20, 2026
  • 3-2
  • 3-2*
  • 3-None
  • 3*None-
Show Solution

The Correct Option is C

Solution and Explanation

Step 1: Run the code and note the output:
Running the code in Python prints 3-None.

Step 2: Explain the first part, 3-:
The call f1(1,2) runs print(1+2, end='-'). The sum is 3 and the end text is a hyphen.
So '3-' is printed and the cursor stays on the same line.

Step 3: Explain the value of c:
A function with no return statement gives back None. The assignment c = f1(1,2) stores None in c.
Note that the function does not give back 3. It only prints it.

Step 4: Explain the second print:
print(c, sep='*') has one argument. The separator sits between two arguments, so here it has no effect.
The output is None followed by a new line.

Step 5: Match with the options:
The text 3- followed by None is 3-None. That is option (C).
Option (A) and (B) show 2 instead of None. Option (D) shows a star that never prints.

Final Answer:
Option (C) 3-None is correct.
Was this answer helpful?
0