Write A Detailed Note About Datatypes and Operators in Python
Write A Detailed Note About Datatypes and Operators in Python
Operators in Python
Python Data Types
A Data Type describes the characteristic of a variable.
These 3 are defined as a class in python. In order to find to which class the variable
belongs to you can use type () function.
#2) String
A string is an ordered sequence of characters.
We can use single quotes or double quotes to represent strings. Multi-line strings
can be represented using triple quotes, ”’ or “””.
Strings are immutable which means once we declare a string we can’t update the
already declared string.
#3) List
A list can contain a series of values.
List variables are declared by using brackets [ ]. A list is mutable, which means we
can modify the list.
#4) Tuple
A tuple is a sequence of Python objects separated by commas.
Tuples are immutable, which means tuples once created cannot be modified. Tuples
are defined using parentheses ().
#5) Set
A set is an unordered collection of items. Set is defined by values separated by a
comma inside braces { }.
#6) Dictionary
Dictionaries are the most flexible built-in data type in python.
Dictionaries items are stored and fetched by using the key. Dictionaries are used to
store a huge amount of data. To retrieve the value we must know the key. In Python,
dictionaries are defined within braces {}.
We use the key to retrieve the respective value. But not the other way around.
Python Operators
Arithmetic operators: Arithmetic operators are used to perform
mathematical operations like addition, subtraction, multiplication and
division.