What type of data structure is the following:
names = {"Jeremy", "Leo", "Dylan"}
Set
What type of data structure is the following:
grades = [98, 100, 82]
List
What type of data structure is the following:
classroom = {
"Trevor": 100,
"Jeremy": 89,
"Hannah": 98,
}
Dictionary
What type of data structure is the following:
student_info = ("Elizabeth", 13, "8th grade")
Tuple
What symbols do we use for dictionaries?
{ : }
What brackets do we use for lists?
[ ]
What brackets do we use for tuples?
( )
What brackets do we use for sets?
{ }
What is the following?
distance = [5, 7, 20, 11, 18]
List
What is the following?
classmates = {
"Billy" : 8,
"Vance" : 12
}
Dictionary
What is wrong with the following tuple?
instruments = {"clarinet", "piano", "drum", "violin"}
It needs to have parentheses
What is wrong with the following dictionary?
classmates = {
"Billy" = 8,
"Vance" = 12
}
It needs colons instead of equal signs
What is wrong with the following set?
colors = "orange", 14, "purple", 4, 5
It doesn't have { } curly brackets
Sets allow different variable types inside the same set.
True or False
True
What will the outcome of this code be?
desserts = ("candy", "popcorn", "soda", "cake")
print(desserts[-1])
cake
Debug the code. Assume that you are creating a tuple.
scores = [12, 39, 4, 70, 10]
scores = (12, 39, 4, 70, 10)
Tuples can be changed.
True or False
False
How can you access the second item in a tuple named 'instruments'?
instruments[1]
What is the output of the following code?
instruments = ("clarinet", "piano", "drum", "violin", "guitar")
print(instruments[1:3])
('piano', 'drum')
The first item in the pairing of a dictionary is called the...
key
The second item in a dictionary pairing is called the...
value
Which data structure is ordered, changeable, and indexed in Python?
Dictionaries
How is data stored in a Python dictionary?
How do you access the value associated with the key "Vance" in the classmates dictionary?
classmates["Vance"]
How do you access the 3rd to last item in a list called snakes?
snakes[-3]