1/77
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What are Python's four primitive data types and what is one key fact about each?
int (unbounded whole numbers),
float (IEEE 754 decimal, imprecise),
bool (subclass of int, True/False), and
str (immutable sequence of Unicode characters).
What is the key difference between a list, a tuple, and a set?
Lists are mutable, ordered, and allow duplicates.
Tuples are immutable, ordered, and allow duplicates.
Sets are mutable, unordered, and do not allow duplicates.
What are the five logging levels in order from lowest to highest severity?
DEBUG (detailed diagnostic info for development),
INFO (confirmation that things are working normally),
WARNING (something unexpected but not breaking),
ERROR (a serious failure that prevented something from completing),
CRITICAL (a severe error that may cause the program to crash or stop).
How does memory management work in Python?
Python uses reference counting as its primary mechanism — when an object's reference count hits zero it's freed immediately. The gc module handles circular references that reference counting can't catch. Memory lives on the heap for objects and the stack for function call frames.
What is inheritance and why do we need it in Python?
Inheritance lets a child class acquire attributes and methods from a parent class, avoiding code duplication. You use it when classes share common behavior but need specialization — e.g. Dog and Cat both inherit from Animal. Python supports single, multiple, multilevel, hierarchical, and hybrid inheritance.
What are some predefined exceptions in Python?
ValueError (right type, wrong value — e.g. int("abc")),
TypeError (wrong type entirely — e.g. "a" + 1),
KeyError (dict key not found),
IndexError (list index out of range),
AttributeError (attribute doesn't exist on the object),
FileNotFoundError (file path doesn't exist),
ZeroDivisionError (division by zero).
What do you know about decorators in Python?
A decorator is a function that wraps another function to add behavior before or after it runs, without modifying the original function. Written with @decorator_name above the function definition. Common uses: logging, timing, access control, caching. Use @functools.wraps inside a decorator to preserve the wrapped function's metadata.
What is the difference between a list and a tuple in Python?
Lists are mutable (you can change them after creation). Tuples are immutable (you cannot). Use a list when data will change; use a tuple when data should stay fixed. Example: coordinates = (40.7, -74.0) as a tuple signals it shouldn't change.