nextRound
TechnologiesCoding ProblemsBookmarksLearning PathsLogin
nextRound
TechnologiesCoding ProblemsBookmarksLearning PathsLogin
nextRound

AI-powered interview preparation platform. Practice with curated questions, mock interviews, and personalized learning paths to crack your dream tech interview.

Quick Links

  • Technologies
  • Mock Interviews
  • Saved Questions
  • Pricing

Company

  • About Us
  • Contact Us

Legal

  • Privacy Policy
  • Terms of Use

© 2026 nextRound. All rights reserved.

Questions
8 of 18
1Why is using a mutable default argument (e.g., `def f(x=[])`) considered a common pitfall?
2What is the purpose of the `nonlocal` keyword, and how does it differ from `global`?
3How does Python's `for` loop differ conceptually from a C-style `for` loop?
4How does structural pattern matching (`match`/`case`, introduced in Python 3.10) differ from a chain of `if`/`elif` statements?
5What are first-class functions, and how does Python's treatment of functions as objects enable higher-order functions?
6What is the purpose of the `else` clause on `for` and `while` loops, and when does it execute?
7How would you implement memoization for a recursive function, and what tradeoffs exist between manual caching and `functools.lru_cache`?
8What is the difference between positional, keyword, default, `*args`, and `**kwargs` parameters?
9Explain Python's LEGB rule for variable scope resolution.
10How does Python's `for` loop differ conceptually from a C-style `for` loop?
11What are first-class functions, and how does Python's treatment of functions as objects enable higher-order functions?
12How would you implement memoization for a recursive function, and what tradeoffs exist between manual caching and `functools.lru_cache`?
13What is the purpose of the `nonlocal` keyword, and how does it differ from `global`?
14What is the difference between positional, keyword, default, `*args`, and `**kwargs` parameters?
15Why is using a mutable default argument (e.g., `def f(x=[])`) considered a common pitfall?
16How does structural pattern matching (`match`/`case`, introduced in Python 3.10) differ from a chain of `if`/`elif` statements?
17What is the purpose of the `else` clause on `for` and `while` loops, and when does it execute?
18Explain Python's LEGB rule for variable scope resolution.
PythonPython
Basics
Control Flow and Functions
Data Structures
Comprehensions & Functional Programming
Iterators, Generators & Decorators
Object-Oriented Programming
Exception Handling & Debugging
Concurrency & Parallelism
Performance & Optimization
Testing
Security
Modules, Packaging & Environment
Type Hinting & Modern Python
System Design & Architecture with Python
Best Practices & Design Patterns
Edge Cases & Tricky Interview Questions
08 / 18

What is the difference between positional, keyword, default, `*args`, and `**kwargs` parameters?

Difficulty: 3/10
Functions & Scope, Function Parameters, args and kwargs

Python's parameter kinds and how arguments bind to them

A Python signature has five kinds of parameters and a fixed order. Positional-or-keyword parameters can be supplied either way. Default parameters give a fallback value if the caller omits them. *args collects extra positional arguments into a tuple. Keyword-only parameters, which come after * or *args, must be named by the caller. **kwargs collects extra keyword arguments into a dict. Since 3.8 you can also mark positional-only parameters with a / in the signature. The full order is: positional-only, /, positional-or-keyword, *args (or bare *), keyword-only, **kwargs.

javascript

How binding works: at call time Python fills positional-only and positional parameters left to right from positional arguments, then matches keyword arguments by name, then applies defaults, and finally raises TypeError for anything missing, duplicated ('multiple values for argument') or unexpected. On the calling side, * and ** unpack iterables and mappings into arguments. Since 3.6 **kwargs preserves the order in which the caller passed the keywords.

Design guidance I give in practice: make rarely used or boolean options keyword-only (def send(to, body, *, retries=3, dry_run=False)) so call sites read clearly and you can add parameters without breaking callers; use positional-only for parameters whose names are not part of the API, which lets you rename them later; and prefer explicit parameters over **kwargs, because **kwargs silently swallows typos like timout=5 unless you validate it. *args and **kwargs are right for decorators, wrappers and forwarding, where you do not know the callee's signature - and use functools.wraps so the wrapper keeps the original's name and docs.

Common mistakes: placing a default before a non-default positional parameter (SyntaxError), reusing a mutable object as a default value (see the mutable default pitfall), and thinking *args is a list (it's a tuple). The positional-only / marker needs Python 3.8+, so mention it if the codebase supports older versions.

Scenario Questions

0-2 years experience

  1. 1For def f(a, b=2, *args, **kwargs), what are a, b, args and kwargs when you call f(1, 3, 4, x=5)?
  2. 2Why is def f(a=1, b): a SyntaxError?

2-5 years experience

  1. 1Design the signature of send_email(to, subject, body, cc, bcc, retries). Which parameters would you make keyword-only, and how does the / marker help API evolution?
  2. 2How do you forward all arguments from a wrapper function to another function, and what do you lose if you forget functools.wraps?

5-8 years experience

  1. 1A widely used function needs a parameter renamed without breaking callers. What migration strategy would you use (deprecation shim, positional-only, **kwargs handling)?
  2. 2A function accepts **kwargs and silently ignores a typo such as timout=5. How would you make the API safer?

8+ years experience

  1. 1Design a plugin or hook system where handlers have different signatures. How would you use inspect.signature to adapt calls, and why might a fixed protocol be better?
  2. 2Explain how Python binds arguments at call time, including the error for duplicate values, and discuss the overhead of *args and **kwargs on a hot path.

Follow-up Questions

  • How would you rename a parameter in a public function without breaking existing callers?
  • Why should a decorator's wrapper use functools.wraps?
Sharethis question

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.