Q:

What will be the output of the following Python code? def f1(a,b=[]): b.append(a) return b print(f1(2,[3,4]))

-1

What will be the output of the following Python code?

def f1(a,b=[]):
   b.append(a)
   return b

print(f1(2,[3,4]))

In the code shown above, the integer 2 is appended to the list [3,4]. Hence the output of the code is [3,4,2]. Both the variables a and b are local variables.


  1. [3,2,4]
  2. [2,3,4]
  3. Error
  4. [3,4,2]

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Correct Answer:

[3,4,2]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python Multiple Choice Questions And Answers

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Program code making use of a given module is calle... >>
<< What will be the output? ef fact(num): if num == 0...