Quiz
Quiz
Introduction to ICT
Tuple:
Tuple is a collection of Python objects much like a list. The sequence of values stored in
a tuple can be of any type, and they are indexed by integers. Values of a tuple are
syntactically separated by ‘commas’. Although it is not necessary, it is more common to
define a tuple by closing the sequence of values in parentheses. The main characteristics
of tuples are:
Tuple is an immutable sequence in python.
It cannot be changed or replaced since it is immutable.
It is defined under parenthesis ().
Tuples can store any type of element.
Set:
Set is an unordered collection of data type that is iterable, mutable, and has no duplicate
elements. The major advantage of using a set, as opposed to a list, is that it has a highly
optimized method for checking whether a specific element is contained in the set. The
main characteristics of set are:
Sets are an unordered collection of elements or unintended collection of items. In
python.
Here the order in which the elements are added into the set is not fixed, it can
change frequently.
It is defined under curly braces {}.
Sets are mutable, however, only immutable objects can be stored in it.
Dictionary:
Dictionary is an unordered collection of data values, used to store data values like a
map, which unlike other Data Types that hold only single value as an element,
Dictionary holds key: value pair. Key value is provided in the dictionary to make it
more optimized. The main characteristics of dictionary are:
Dictionary can be created by placing sequence of elements within curly {} braces,
separated by ‘comma’.
Dictionary holds a pair of values, one being the Key and the other corresponding
pair element being its key: value.
Values in a dictionary can be of any data type.
Values can be duplicated whereas keys can’t be repeated must be immutable.
Items in list can be Items in set cannot be Items in tuple cannot be Item in dictionary can
replaced or changed replaced or changed replaced or changed be replaced or changed.
Items in list are bounded Items in set are bounded Items in tuple are Items in dictionary are
by square brackets [] by curly brackets {} bounded by round bounded by curly
brackets () brackets {}