Data types Flashcards
What is a Boolean value?
A Boolean is a special kind of variable that only takes on one of two possible values: True or False
What is a list?
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.
What is a set?
A collection of unique elements, delimited by curly braces
( { and } ). The order does not matter and set is mutable
What is a dict?
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.
What is a tuple?
A collection of objects represented by comma-delimited values enclosed in round bracket. Unlike lists, they are immutable.
What is the advantage of using tuple over a list in storing data?
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