Python 39

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

1/16

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 6:25 PM on 9/19/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

17 Terms

1
New cards

Dictionary

A dictionary is a collection of unordered, modifiable(mutable) paired (key: value) data type.
use it when you have a massive database and need to find a specific item instantly without checking every single one.


2
New cards

List

OPTIMIZED FOR ORDER, SEQUENCES, AND QUEUES
use it when the order of events matters and to keep track of a timeline (1st, 2nd, 3rd, etc.).


3
New cards

Tuple

A tuple is a collection of different data types which is ordered and unchangeable (immutable). Tuples are written with round brackets, (). Once a tuple is created, we cannot change its values. We cannot use add, insert, remove methods in a tuple because it is not modifiable (mutable). Unlike list, tuple has few methods. Methods related to tuples:


4
New cards

Set

a set is essentially a dictionary that only stores keys without associated values.


5
New cards

List Add

fruits.append('apple')          # add
fruits.insert(1, 'grape')       # Insert at index 1


6
New cards

List Modify

fruits[0] = 'strawberry'        # modify


7
New cards

List Access

first_item = fruits[0]          # access
subset = fruits[1:3]            # Slicing from index 1 up to 3


8
New cards

List Remove

fruits.remove('mango')         
del fruits[0]                    # Removes item at index 0
popped_item = fruits.pop()       # Removes and returns last item


9
New cards

Dict Add


items["Iron Shield"] = {"type": "armor", "defense": 8, "price": 15} # add


10
New cards

Dict Modify

items["Rusty Sword"]["damage"] = 7  # modify


11
New cards

Dict Access

sword_stats = items["Rusty Sword"]            # access
damage = items["Rusty Sword"]["damage"]           # 7
shield_stats = items.get("Iron Shield", "Not found")


12
New cards

Dict Remove

del items["Rusty Sword"]["price"]                 # Deletes the nested 'price' key
removed_item = items.pop("Iron Shield")           # Removes and returns the entry


13
New cards

Tuple Add

fruits = fruits + ('peach',)        # add


14
New cards

Tuple Modify

temp_list = list(fruits)            # modify
temp_list[0] = 'strawberry'
fruits = tuple(temp_list)


15
New cards

Tuple Access

first_fruit = fruits[0]              # access
middle_fruits = fruits[1:3]          # ('orange', 'mango')


16
New cards

Tuple Remove

fruits = fruits[1:]                  # Slices off the first element
del fruits                           # Deletes the entire variable reference


17
New cards