Topic 7 - Working with Dictionaries and Sets Flashcards

1
Q

What type of brackets are used with dictionaries in python?

A

Curly brackets, i.e. { }

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

A python dictionary is defined using what two elements?

A

The two elements are keys and values.

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

Is a dictionary in python mutable or immutable?

A

A dictionary is mutable

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

What function would you use to determine how many key/values pairs are in the dictionary “bike_details”

A

len(bike_details)

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

What function is used to remove all key/values pairs from a dictionary?

A

Use the function clear, i.e. bike_details.clear()

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

How would you delete a dictionary entirely?

A

del bike_details

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

Why would you use a set in python?

A

It you needed to contains values where no duplicates are allowed.

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

Is a tuple mutable or immutable?

A

It is immutable, i.e. it can not be changed.

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