SBL 2 A16
SBL 2 A16
NUMERIC:
In Python, numeric data type represents the data which has numeric
value. Numeric value can be integer, floating number or even complex
numbers. These values are defined as int, float and complex class in
Python.
SEQUENCE:
In Python, sequence is the ordered collection of similar or different
data types. Sequences allows to store multiple values in an organized
and efficient fashion. There are several sequence types in Python –
• String
• List
• Tuple
BOOLEAN:
Data type with one of the two built-in values, True or False. Boolean
objects that are equal to True are truthy (true), and those equal to False
are falsy (false). But non-Boolean objects can be evaluated in Boolean
context as well and determined to be true or false. It is denoted by the
class bool.Note – True and False with capital ‘T’ and ‘F’ are valid
booleans otherwise python will throw an error.
SET:
In Python, Set is an unordered collection of data type that is iterable,
mutable and has no duplicate elements. The order of elements in a set
is undefined though it may consist of various elements.
Creating Sets
Sets can be created by using the built-in set () function with an iterable
object or a sequence by placing the sequence inside curly braces,
separated by ‘comma’. Type of elements in a set need not be the same,
various mixed-up data type values can also be passed to the set.
DICTIONARY:
Dictionary in Python 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. Each key-
value pair in a Dictionary is separated by a colon:, whereas each key is
separated by a ‘comma’.
Creating Dictionary
In Python, a Dictionary can be created by placing a sequence of
elements within curly {} braces, separated by ‘comma’. Values in a
dictionary can be of any datatype and can be duplicated, whereas keys
can’t be repeated and must be immutable. Dictionary can also be
created by the built-in function dict(). An empty dictionary can be
created by just placing it to curly braces {}.
Note – Dictionary keys are case sensitive, same name but different
cases of Key will be treated distinctly.
SYNTAX:
NUMERIC