![]() |
Python Data Types With Example in 2021 |
What are the 4 data types in Python?
Python Data Types: A Python Data type is used in a python program. There is no need for data types to declare a variable in data types. Python pre-defined data types in python language.
like int, float, char, etc, no need to declare in variable python automatic declared data types defined in the python program.
Important Same Other Languages Data_Types
👉Java Data Types
👉C Data Types
👉C++ Data Types
Integer Data Types: A integer data type can be used without decimal numbers.
integer data type python program runs automatically no declared data types.it is called the integer data type in the python language.
Example of Integer Data Types
int a=100 /it is valid data types
a=100/it is valid data types
How To Use Integer Data Types in Python?
int a=100
int b=200
print("value of a:",a)
print("value of b:",b)
print("Data type:",type(a))
print("Data type:",type(b))
*****OUTPUT*****
value of a: 100
value of b: 200
Data types: <class 'int'>
Data types: <class 'int'>
int a=100
int b=200
print("value of a:",a)
print("value of b:",b)
print("Data type:",type(a))
print("Data type:",type(b))
*****OUTPUT*****
value of a: 100
value of b: 200
Data types: <class 'int'>
Data types: <class 'int'>
Example of Float Data Types
a=30.5
b=23.23
c=47.43
How To Use Float Data Types in Python?
a=25.65
b=28.45
print("value of a:",a)
print("value of b:",b)
print("Data type:",type(a))
print("Data type:",type(b))
*****OUTPUT*****
value of a: 25.65
value of b: 28.45
Data types: <class 'float'>
Data types: <class 'float'>
a=25.65
b=28.45
print("value of a:",a)
print("value of b:",b)
print("Data type:",type(a))
print("Data type:",type(b))
*****OUTPUT*****
value of a: 25.65
value of b: 28.45
Data types: <class 'float'>
Data types: <class 'float'>
Complex Data Types: A Complex data type combination of the first real part and second imaginary part in complex data types.
Example of Complex Data Types
5+3j
2+5j
How To Use Complex Data Types in Python?
a=5+2j
b=3+4j
print("complex value of a:",a)
print("complex value of b:",b)
print("Data type:",type(a))
print("Data type:",type(b))
*****OUTPUT*****
complex value of a: 5+2j
complex value of b: 3+4j
Data types: <class 'complex'>
Data types: <class 'complex'>
a=5+2j
b=3+4j
print("complex value of a:",a)
print("complex value of b:",b)
print("Data type:",type(a))
print("Data type:",type(b))
*****OUTPUT*****
complex value of a: 5+2j
complex value of b: 3+4j
Data types: <class 'complex'>
Data types: <class 'complex'>
Strings Data Type: A String is a sequence of characters. The string is using single and double-quotes.
it is called string short data in python program str.
Example of Strings Data Types
a="Welcome to icoderweb"
b="Welcome Python Language"
Program of Strings Data Types
a="Welcome to icoderweb"
b="Welcome Python Language"
print("String value of a:",a)
print("String value of b:",b)
print("Data type:",type(a))
print("Data type:",type(b))
*****OUTPUT*****
The string value of a: Welcome to icoderweb
The string value of b: Welcome Python Language
Data types: <class 'str'>
Data types: <class 'str'>
a="Welcome to icoderweb"
b="Welcome Python Language"
print("String value of a:",a)
print("String value of b:",b)
print("Data type:",type(a))
print("Data type:",type(b))
*****OUTPUT*****
The string value of a: Welcome to icoderweb
The string value of b: Welcome Python Language
Data types: <class 'str'>
Data types: <class 'str'>