DATA TYPES IN PYTHON
Each Python value has a data type. Since everything is a programming object in Python, data types are classes and variables are objects of classes.
SkyInfotech is the best institute for Python
programming language and provides the best training of Python by the expert of
industry.
There are
different types of data in Python. Some of the important types are listed
below.
PYTHON NUMBERS
Integers,
floating-point numbers, and complex numbers fall under the Python number
category. These are called int, float, and complex Python classes.
With the
function type () we can determine which class a variable or value belongs to.
Similarly, the function () function checks whether an object belongs to a
certain class.
Integers can be
of any length and are limited to the available memory.
A floating
number is accurate to 15 decimal places. Integers and floating-point numbers
are separated by decimal places. 1 is an integer, 1.0 is a floating-point
number.
The complex
numbers are written in the form x + yj, where x is the real part, and y is the
imaginary part. Here are some examples.
PYTHON LIST
The list is an
ordered order of the articles. It is one of the most common data types in
Python and very flexible. All items in a list do not have to be of the same
type.
Announcing a
list is pretty easy. Items separated by commas are enclosed in brackets [].
We can use the
slicing operator [] to get an article or a series of articles from a list. The
index in Python starts at 0.
PYTHON TUPLE
A tuple is an
ordered order of elements that are identical in a list. The only difference is
that tuples cannot be changed. Previously created tuples cannot be changed.
Tuples are used
to write data protection and are often faster than lists because they cannot
change dynamically.
This is defined
in parentheses (), in which the elements are separated by commas.
PYTHON STRINGS
A string is a
sequence of Unicode characters. We can use single or double quotes to represent
strings. Multi-line strings can be specified with the triple quotation mark ''
'or "" ".
PYTHON SET
The set is an
independent collection of unique items. The set is defined by the values
separated by a comma in curly braces {}. Items in a set are not ordered.
DICTIONARY OF PYTHON
A dictionary is
an unrelated collection of value pairs.
It is often used
when we have a large amount of data. Dictionaries are optimized for data
retrieval. We need to know the key to get the value.
In Python,
dictionaries are defined within the quarters {} of each element as a pair in
the key: the value. The key and value can be of any type.
Comments
Post a Comment