1/9
A set of flashcards covering key concepts related to immutable vs. mutable objects and the scope of variables in Python.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Immutable Objects
Objects that cannot be changed after being created; they can only be overwritten with new values in new memory locations.
Mutable Objects
Objects that can be changed after being created.
Types of Immutable Objects in Python
bool, int, float, str, and tuples.
Types of Mutable Objects in Python
list, dict, and set.
Pass by Value
A simulation of passing by value occurs with immutable objects, where changes inside a function do not reflect in the original variable.
Pass by Reference
All variables are passed by reference, meaning the reference to their memory location is passed to the function.
Local Variables
Variables that are only accessible within the function where they are defined and exist until the function finishes executing.
Global Variables
Variables declared outside of any function, which are accessible from anywhere in the program.
Variable Lifetime
The duration that a variable occupies memory, allocated at declaration time and existing until the program terminates for global variables or until function completion for local variables.
Scope of a Variable
The section of code where a variable is accessible, including local and global scopes.