T

Tanmay • 2.43K Points
Master

Q. What is the output of the following code?

Code:
def add(init = 5, *nbr, **key):
   c = init
   for n in nbr:
      c+=n
   for k in key:
      c+=key[k]
   return c
print(add(100,2,2, x=20, y=10))
  • (A) 136
  • (B) 134
  • (C) 100
  • (D) 122
  • Correct Answer - Option(B)
  • Views: 148
  • Filed under category Python

Explanation by: Tanmay
The function adds 2, 2, 20 and 10 to the initial value 100, so the result is 134

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.


Question analytics