Functions & Scope · Question 7 · Easy

A function is defined as def book(src, dst, seats=1). Which of these calls is NOT valid Python?

  1. book(src="Pune", "Goa")
  2. book("Pune", "Goa")
  3. book("Pune", dst="Goa")
  4. book(dst="Goa", src="Pune", seats=2)
Answer and explanation

Answer: A. book(src="Pune", "Goa")

Explanation: A positional argument can never come after a keyword argument, so book(src="Pune", "Goa") is a SyntaxError. The other three calls supply src and dst correctly.

Previous: A function assigns to a name that also exists at module level. What does this… · Next: The tag function uses a dictionary as a default parameter value. What do the…

Practise functions & scope

Try a fresh set of functions & scope questions with an explanation after every answer, free and without signing up: Functions & Scope practice. Or sit a full placement mock test.

More functions & scope questions

More python practice

Comprehensions & Generators · Classes & Objects · Exceptions & Files · Built-ins & Standard Library · Variables, Types & Operators · Python Strings · Lists & Tuples · Dictionaries & Sets

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge