[]) syntax for creating a list0) with square brackets ([]) as well()) syntax for creating a tuple0) with square brackets ([])key: value{}) with key and value separated by colon (:)[])A set is (another) data structure
Helpful ways of thinking about it
A dictionary without the values
A “bag” of elements
Do not store items in the order you created them
Do not allow repeated items to be stored
Cannot use square brackets to retrieve an item
Use set() to initiate an empty set
Use len() to get number of items
Use for x in set to iterate over the elements in a set
.add(value) adds an element to the set.discard(value) discards the specified valueYou can also use the operator in and the function len() with sets
Use the function set() to convert a list to a set, and list() to convert a set into a list
numbers_list = [2, 1, 2, 1, 3, 4, 1]
numbers_list # evaluate this line
numbers_set = set(numbers_list)
numbers_set # evaluate this line
numbers_set.add(1)
numbers_set.add(2)
numbers_set # evaluate this line
numbers_set.add(5)
numbers_set # evaluate this line
numbers_set.discard(6)
numbers_set.discard(1)
numbers_set # evaluate this lineGo to gradescope and evaluate the code for today’s attendance question
count_nameshas_duplicates*valuesTrue if there are repeated elements in values, False otherwise