Mind map
Four Basic Data Structures
Map content
Four Basic Data Structures
Lists
- [...,...,...]
- myList = ["lemon", "banana", True, 2, 12]
- includes Strings, boolean, and integers
- there are 4 indexes: 0,1,2,3
- myList = ["lemon", "banana", True, 2, 12]
- appendable/changeable
- Add or Remove elements from the list
- myList.append
- myLIst.remove("lemon")
- Add or Remove elements from the list
- [...,...,...]
Dictionaries
- key:value
- carOnSale = { "brand": "Toyoya", "model": "Corolla", "year": 2018, "sold": True
- access elements
- print(carOnSale)
- carOnSale["color"] = "silver"
- theBrand = carOnSale["brand"]
- describe items; used to store data
- key:value
Tuples
- unchangeable
- cannot add or remove elements
- myTuple = ("meow", 32, False, "silly")
- (...,...,...)
- unchangeable
Sets
- unordered and rejects duplicates
- to check if an element exists
- Loop:
- for x in mySet: print(x)
- True or False
- print("banana" in mySet
- Loop:
- to check if an element exists
- {...,...,...}
- mySet = {"lemon", "banana", False, 2}
- add elements
- mySet.add("apple")
- merge to Sets
- mySet.update(newSet)
- unordered and rejects duplicates
ordered and allows duplicates (both Tuples and Lists)
- to access an element
- item = myList[2]
- to access an element
- item= myTuple[1]
- returns "32"
- myTuple[-1]
- returns last item "False"
- myTuple[1:3]
- returns index 1 AND 2 AND 3 32, False, "silly"
- item= myTuple[1]
- to access an element
Information
- Description
- Computer Science Mind Map on Four Basic Data Structures, created by Jovain Sterling on 19/09/2021.
- Created by
- Jovain Sterling
- Views
- 0
- Rating