Dictionary Methods Flashcards

1
Q

Definition dictionary

A

A dictionary is a collection which is unordered changeable and indexed.

Syntax curly brackets {“key”: “value”}

dict = {
“Brand”: “Ford”
“Year”: 1963
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

dict.copy()

A

Returns a copy of the dictionary.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

dict.fromkeys()

A

Returns a dictionary with the specified keys and values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

dict.get()

A

Returns the value of the specified key.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

dict.items

A

Returns a list containing a tulle for each key value pair.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

dict.keys()

A

Returns a list containing the dictionaries keys.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

dict.pop()

A

Removes an element with specified key.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

dict.popitem()

A

Removes the last inserted key-value pair.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

dict.setdefault()

A

Returns the value of the specified key. If the key doesn’t exist insert the key with specified value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

dict.update()

A

Updates the dictionary with the key-value pair.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

dict.values()

A

Returns a list of all the values in the dictionary.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

dict.clear()

A

Removes all elements from the dictionary.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly