ProgrammingModerateInfosys · Accenture · Capgemini pattern
What is printed?
What is printed?
def f(*args, **kw):
print(len(args), len(kw))
f(1, 2, a=3)- A. 2 1
- B. 1 2
- C. 3 0
- D. 3 1
Correct answer: A. 2 1
Positional arguments go into the tuple args, here (1, 2). Keyword arguments go into the dict kw, here {'a': 3}. So the lengths are 2 and 1.
More Python Programming questions
- What is printed? python print(list(zip([1, 2, 3], "ab")))
- What is printed? python print(" ".join(sorted(set("banana"))))
- What is printed? python try: print(1 / 0, end=" ") except ZeroDivisionError: print("Z", end=" ") finally: print("F")
- What is printed? python print(list(range(10, 0, -3)))
- What is printed? python print(max("apple", "Banana", "cherry"))
- What is printed? python print(round(2.5), round(3.5), round(-0.5))