Python Functions & Lambdas MCQ Test: 200 Interview Questions With Answers

← All Python MCQ topics and your readiness dashboard

Test your Functions, Arguments and Lambdas knowledge with a timed Python MCQ mock test for interviews. Each attempt gives you 20 random questions in 20 minutes from a 200-question bank covering return values, positional, keyword, default, *args, **kwargs, keyword-only and positional-only parameters, mutable default arguments, LEGB scope with global and nonlocal, closures and late binding, lambdas with map, filter and sorted, recursion, functools partial, lru_cache and wraps, type hints, and test helpers, factories, retry and polling functions for QA. 49 questions are written from a QA and test-automation angle and the rest from a developer angle; your result shows both scores.

What this Python MCQ test covers

Revise these lessons from the free Python tutorial before or after your test:

Sample Python Functions & Lambdas questions with answers

  • Q. A retry helper for a flaky call. What does this code print?
    def retry(fn, attempts=3):
    for i in range(1, attempts + 1):
    try:
    return fn(i)
    except ValueError:
    pass
    raise RuntimeError("gave up")
    def flaky(i):
    if i < 3:
    raise ValueError
    return f"ok on {i}"
    print(retry(flaky))

    Answer: ok on 3
    The helper tries again on ValueError and returns as soon as a call succeeds.
  • Q. A test-data factory with overrides. What does this code print?
    def make_user(**overrides):
    user = {"name": "test", "role": "viewer", "active": True}
    user.update(overrides)
    return user
    print(make_user(role="admin")["role"], make_user()["role"])

    Answer: admin viewer
    A factory with **overrides gives sensible defaults and lets each test change only what it needs.
  • Q. Building unique test emails. What does this code print?
    import itertools
    _seq = itertools.count(1)
    def unique_email(prefix="qa"):
    return f"{prefix}{next(_seq)}@test.dev"
    unique_email()
    print(unique_email(), unique_email("dev"))

    Answer: qa2@test.dev dev3@test.dev
    A shared counter guarantees unique emails across calls.
  • Q. What does this code print?
    def greet(name):
    return "Hi " + name
    print(greet("Asha"))

    Answer: Hi Asha
    The function returns the joined string, which print shows.
  • Q. What does this code print?
    def greet(name):
    print("Hi", name)
    result = greet("Ravi")
    print(result)

    Answer: Hi Ravi None
    A function without return gives None, after printing inside.
  • Q. What does this code print?
    def f():
    return
    print(f())

    Answer: None
    A bare return returns None.

Every predict-the-output question in this bank was run on Python 3, so the answer is the real output. Go back to the Python MCQ dashboard to see your overall Python learning progress and interview readiness.

Frequently asked questions

How many questions does the Python Functions & Lambdas MCQ test have?

The bank has 200 questions. Each test picks 20 at random, favouring questions you have not seen yet, so about 10 attempts cover the whole bank.

How long is each test and what is the pass mark?

Each test has a 20-minute timer and submits itself when time runs out. You pass with 70%, which is 14 of 20 correct.

Is this test useful for QA and automation engineer interviews?

Yes. 49 of the questions use test-automation scenarios such as parsing UI text, test data and assertions, and your result shows your QA score separately.

Can I retake the test?

Yes, as often as you like. Every retake draws a fresh set of 20 questions and counts toward your 20-test readiness target.