Data types Flashcards

1
Q

What is a Boolean value?

A

A Boolean is a special kind of variable that only takes on one of two possible values: True or False

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

What is a list?

A

A collection of objects in a sequence, delimited by square brackets ( [ and ] ). The objects do not need to be all of the same type and list is mutable.

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

What is a set?

A

A collection of unique elements, delimited by curly braces

( { and } ). The order does not matter and set is mutable

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

What is a dict?

A

A set of key-value pairs. The first element in each pair is the key and the second element is the value. The key can be used to look up the value.

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

What is a tuple?

A

A collection of objects represented by comma-delimited values enclosed in round bracket. Unlike lists, they are immutable.

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

What is the advantage of using tuple over a list in storing data?

A

Tuples make code safer
Using a tuple instead of a list is akin to implying that the data stored is
constant
A user cannot accidentally modify the elements in a tuple because
tuples are immutable

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