Immutable vs. Mutable Objects and Scope of Variables

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/9

flashcard set

Earn XP

Description and Tags

A set of flashcards covering key concepts related to immutable vs. mutable objects and the scope of variables in Python.

Last updated 7:41 PM on 3/9/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

10 Terms

1
New cards

Immutable Objects

Objects that cannot be changed after being created; they can only be overwritten with new values in new memory locations.

2
New cards

Mutable Objects

Objects that can be changed after being created.

3
New cards

Types of Immutable Objects in Python

bool, int, float, str, and tuples.

4
New cards

Types of Mutable Objects in Python

list, dict, and set.

5
New cards

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.

6
New cards

Pass by Reference

All variables are passed by reference, meaning the reference to their memory location is passed to the function.

7
New cards

Local Variables

Variables that are only accessible within the function where they are defined and exist until the function finishes executing.

8
New cards

Global Variables

Variables declared outside of any function, which are accessible from anywhere in the program.

9
New cards

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.

10
New cards

Scope of a Variable

The section of code where a variable is accessible, including local and global scopes.