CHAP 9 COSC 1010

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/32

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

33 Terms

1
New cards

dictionary

object that stores a collection of data, consists of a key and value

2
New cards

retrieve value

dictionary_name[key]

3
New cards

add elements

dictionary[key]=value

4
New cards

delete elements

del dictionary[key]

5
New cards

len function

6
New cards

empty dictionary

use {}

7
New cards

for loop

for key in dictionary:, for item in set:

8
New cards

clear method

deletes all the elements in a dictionary, leaving it empty (dictionary.clear())

9
New cards

get method

gets a value associated with specified key from the dictionary (dictionary.get(key, default))

10
New cards

items method

returns all the dictionaries keys and associated values (dictionary.items())

11
New cards

keys method

returns all the dictionaries keys as a sequence (dictionary.keys())

12
New cards

pop method

returns value associated with specified key and removes that key-value pair from the dictionary (dictionary.pop(key, default))

13
New cards

popitem method

Returns, as a tuple, the key-value pair that was last added to the dictionary, also removes the key-value pair from dictionary (dictionary.popitem())

14
New cards

values method

returns all the dictionaries values as a sequence (dictionary.values())

15
New cards

dictionary comprehension

an expression that reads a sequence of input elements and uses those input
elements to produce a dictionary (squares={item**2 for item in numbers})

16
New cards

set

object that stores a collection of data in same way as mathematical set (mutable)

17
New cards

set function

used to create a set, empty set call set(), non-empty call set(argument)

18
New cards

len function

returns the number of elements in the set

19
New cards

add method

adds an element to a set

20
New cards

update method

adds a group of elements to a set, elements must be iterable

21
New cards

remove + discard methods

remove the specified item from the set, remove raises KeyError, discard does not

22
New cards

clear method

clears all the elements of the set

23
New cards

in operator

used to test whether a value exists in set, not in as well

24
New cards

union of two sets

a set that contains all the elements of both sets (set3=set1.union(set2) or set1 | set2)

25
New cards

intersection of two sets

a set that contains only the elements found in both sets (set3=set1.intersection(set2) or set1 & set2)

26
New cards

difference of two sets

a set that contains elements that appear in the first set but do not appear
in second set (set3=set1.difference(set2) or set1-set2)

27
New cards

symmetric difference of two sets

a set that contains the elements that are not shared by the two sets (set1.symmetric_difference(set2) or set1^set2)

28
New cards

subset

Set A is subset of set B if all the elements in set A are included in set B (setA.issubset(setB) or setA <= setB)

29
New cards

superset

Set A is superset of set B if it contains all the elements of set B (setA.issuperset(setB) or setA >= setB)

30
New cards

set comprehension

a concise expression that creates a new set by iterating over the elements of a
sequence (set2={item for item in set1})

31
New cards

serialize an object

convert the object to a stream of bytes that can easily be stored in a file

32
New cards

pickling

serializing an object, import pickle (pickle.dump(object, file)) then close

33
New cards

unpickling

retrieving pickled object, import pickle then open file (pickle.load(file)) then close