Mapa mental
Linear Data Structures
Conteúdo do mapa
Linear Data Structures
Lists
- Ordered: elements of a list can be accessed using their indexes
- Changeable: elements can be added to or deleted from the list
- Allow duplicates: multiple elements can be the same
- Elements in the list can be of different data types
- petExample = [ "dog", "golden retriever", 3, True]
- To add an element: petExample.append("Penny")
- petExample = ["dog", "golden retriever", 3, True, "Penny"]
- To delete an element: petExample.remove(3)
- petExample = ["dog", "golden retriever", True, "Penny"]
- To access an element: petType = petExample[0]
- petType = "dog"
- To access an element: petType = petExample[0]
- petExample = ["dog", "golden retriever", True, "Penny"]
- To delete an element: petExample.remove(3)
- petExample = ["dog", "golden retriever", 3, True, "Penny"]
- To add an element: petExample.append("Penny")
Tuples
- Ordered: elements of a tuple can be accessed using their indexes
- Unchangeable: elements cannot be added to or deleted from the tuple
- Allow duplicates: multiple elements can be the same
- Elements in the tuple can be of different data types
- petExample = ("dog", "golden retriever", 3, True)
- petName = ("Penny",)
- To access an element: petType = petExample[0]
- petType = "dog"
- To access multiple elements: print(petExample[1:3])
- ('golden retriever', 3)
- To access multiple elements: print(petExample[1:3])
- petType = "dog"
- To access an element: petType = petExample[0]
- petName = ("Penny",)
Sets
- Unordered: elements of a set cannot be accessed using their indexes
- Unchangeable: elements cannot be changed, but elements can be added
- Reject duplicates: multiple elements cannot be the same
- Elements in the set can be of different data types
- petExample = {"dog", "golden retriever", 3, True}
- To add an element: petExample.add("Penny")
- Two sets can be merged: petStats = {"Medium", 25}
- petExample.update(petStats)
- petExample = {"dog", "golden retriever", 3, True, "Penny", "Medium", 25}
- petExample.update(petStats)
- Two sets can be merged: petStats = {"Medium", 25}
- To add an element: petExample.add("Penny")
Dictionaries
- Unordered: elements of a dictionary cannot be accessed using their indexes
- Changeable: elements can be added to and changed in the dictionary
- Reject duplicates: multiple keys cannot be the same
- Elements in the dictionary can be of different data types
- Stores data in the dictionary in key : value format
- key : value "age" : 19
- petExample = { "pet type" : "dog", "breed" : "golden retriever", "age" : 3, "fixed" : True}
- To add a key : value: petExample["name"] = "Penny"
- To change a value in one of the keys: petExample["age"] = 4
- petExample = { "pet type" : "dog", "breed" : "golden retriever", "age" : 4, "fixed" : True, "name" : "Penny"}
- To access a value in a key: theBreed = petExample["breed"]
- theBreed = "golden retriever"
- To access a value in a key: theBreed = petExample["breed"]
- petExample = { "pet type" : "dog", "breed" : "golden retriever", "age" : 4, "fixed" : True, "name" : "Penny"}
- To change a value in one of the keys: petExample["age"] = 4
- To add a key : value: petExample["name"] = "Penny"
- petExample = { "pet type" : "dog", "breed" : "golden retriever", "age" : 3, "fixed" : True}
- key : value "age" : 19
Informações
- Descrição
- Mapa Mental sobre Linear Data Structures, criado por Alyssa M. em 26-01-2021.
- Criado por
- Alyssa M.
- Visualizações
- 0
- Avaliação