KEYWORDS USED IN PYTHON
DATA TYPES
Numeric Any representation of data which
has numeric value. Python identifies
three types of numbers – integer,
float and complex number.
Positive and negative whole numbers.
Integer
Examples: 1234, -234, 0x46 (hexadecimal
number), 0O123 (octal number))
Note: In C and related programming languages
such as Python, a hexadecimal number is
prefixed with 0x and an octal number is prefixed
with 0O.
Real numbers with a floating point representation
Float in which the fractional component is denoted by
a decimal or scientific notation
Examples: -55.550, 0.005, 1.32E10 (scientific
notation))
A number with a real and imaginary component
Complex number is represented as a + bj inPython where a and b
are floats and
j = √-1
Examples: 4+6j, -2.3+6.4j
Note: The common mathematical representation
of a complex number uses a +bi with i being the
imaginary part. But in electronics j is used
because i already represent current and the next
letter after i is j.
Boolean Any representation of data which
has two values denoted by True and
False.
Sequence An ordered collection of similar or
different data types. The built-in
Sequence data types in Python are
– String, List, and Tuple.
A collection of one or more characters put in
String single, double or triple quotes.
Examples: ‘Hello’, "Hello", "'Hello'", """Hello"""
An ordered collection of one or more data items,
List not necessarily of the same type, put in square
brackets.
Examples: [1,"Ravi",75.50, True]
An ordered collection of one or more data items,
Tuple not necessarily of the same type put in
parentheses. The contents of a tuple cannot be
modified – it is immutable - after the tuple is
created.
Examples: (1,"Ravi", 75.50, True)
Note: Refer to the Helper Text to learn more
about mutability.
An unordered collection of data in key:value pair
Dictionary form. Collection of such pairs is enclosed in curly
brackets.
Example: {1:"Superman", 2:"Wonder Woman",
3:"Thor", 4: "Hulk", 5:"Black Widow"}