Module 2: Python Collection Data Types

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

1/39

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.

40 Terms

1
New cards

four

There are ____ collection data types in the Python programming language

2
New cards

List

_____ is a collection which is ordered and changeable. Allows duplicate members

3
New cards

Tuple

_____ is a collection which is ordered and unchangeable. Allows duplicate members

4
New cards

Set

____ is a collection which is unordered, unchangeable, and unindexed. No duplicate members.

5
New cards

Dictionary

______ is a collection which is ordered and changeable. No duplicate members

6
New cards

Lists

_____ are used to store multiple items in a single variable and are created using square brackets

7
New cards

len()

To determine how many items a list has, use the ____ function

8
New cards

end

Negative indexing means start from the ____

9
New cards

append()

To add an item to the end of the list, use the ______ method

10
New cards

insert()

To insert a new list item, without replacing any of the existing values, you can use the _____ method

11
New cards

extend()

To append elements from another list to the current list, use the ____ method

12
New cards

remove()

The _____ method removes the specified item

13
New cards

pop()

The _____ method removes the specified index

14
New cards

last

If you do not specify the index, the pop() method removes the ____ item

15
New cards

del

____ keyword also removes the specified index

16
New cards

del

The ___ keyword can delete the list completely

17
New cards

clear()

The _____ method empties the list

18
New cards

Tuples

_____ are used to store multiple items in a single variable and are written with parenthesis

19
New cards

comma

To create a tuple with only one item, you have to add a _____ after the item, otherwise Python will not recognize it as a tuple

20
New cards

immutable

Tuples are unchangeable, or ______ as it also is called

21
New cards

Sets

_____ are used to store multiple items in a single variable and are created using curly brackets

22
New cards

add()

To add an item to a set, use the ____ method

23
New cards

update()

To add items from another set into the current set, use the ______ method

24
New cards

remove(), discard()

To remove an item in a set, use the ______, or the ______ method

25
New cards

raise

If the item to remove does not exist, remove() will _____ an error

26
New cards

not raise

If the item to remove does not exist, discard() will ______ an error

27
New cards

union()

The ______ method returns a new set with all items from both sets

28
New cards

update()

The _____ method inserts the items in set two into set one

29
New cards

intersection_update()

The _______ method will keep only the items that are present in both sets

30
New cards

intersection()

The ______ method will return a new set, that only contains the items that are present in both sets

31
New cards

symmetric_difference_update()

The __________ method will keep only the elements that are NOT present in both sets

32
New cards

symmetric_difference()

The _______ method will return a new set, that contains only the elements that are NOT present in both sets

33
New cards

Dictionaries

_______ are used to store data values in key:value pairs and are written in curly brackets

34
New cards

keys()

The ____ method will return a list of all the keys in the dictionary

35
New cards

values()

The ______ method will return a list of all the values in the dictionary

36
New cards

update()

The ____ method will update the dictionary with the items from a given argument.

37
New cards

pop()

The ___ method removes the item with the specified key name

38
New cards

popitem()

The _____ method removes the last inserted item in dictionary

39
New cards

del

The ___ keyword removes the item with the specified key name

40
New cards

clear()

The ____ method empties the dictionary