Python Programming Fundamentals

Core Python concepts every developer should know.

12 cards ยท by @demo
Log in to clone
Front

What is a list comprehension?

Back

[expr for item in iterable if condition] โ€” a concise way to build lists. E.g. [x**2 for x in range(10) if x % 2 == 0]

Front

What is the difference between a list and a tuple?

Back

Lists are mutable (can be changed), tuples are immutable. Tuples use () and are faster; lists use [].

Front

What does *args do in a function signature?

Back

Collects extra positional arguments into a tuple, allowing a function to accept any number of positional args.

Front

What does **kwargs do?

Back

Collects extra keyword arguments into a dictionary, letting a function accept any number of named args.

Front

What is a decorator?

Back

A function that wraps another function to extend its behaviour without modifying it. Applied with @decorator_name.

Front

Explain Python's GIL

Back

The Global Interpreter Lock prevents multiple native threads from executing Python bytecode simultaneously, limiting CPU-bound parallelism in CPython.

Front

What is a generator?

Back

A function that yields values one at a time using 'yield', producing an iterator without storing all values in memory.

Front

What is the difference between '==' and 'is'?

Back

'==' checks value equality; 'is' checks identity (same object in memory). E.g. [1,2] == [1,2] โ†’ True, but [1,2] is [1,2] โ†’ False.

Front

What are Python's built-in data types?

Back

int, float, complex, str, bytes, list, tuple, range, dict, set, frozenset, bool, NoneType

Front

What is a context manager?

Back

An object implementing __enter__ and __exit__ used with 'with' statements to manage resources (e.g. files, locks) and guarantee cleanup.

Front

How does Python handle memory management?

Back

Via reference counting and a cyclic garbage collector. Objects are freed when their reference count drops to zero.

Front

What is a lambda function?

Back

An anonymous single-expression function: lambda args: expression. E.g. square = lambda x: x**2