Data Types in Python Programming

Data Types in Python Programming
Data Types in Python Programming


Basic Data Type in Python

Data TypeLiteralExample
Integer10x=10
Float56.8y=56.8
Complex5 8ja=5 8j
String"Jiocoding"s="jiocoding"
BooleanTrue/Falsex=True

Integer Data Type in Python

Integers Data Type: Any literal that includes only numeric characters (0 to 9) creates an object of type int. An object declared in this way can be referenced by a variable using the assignment operator.

Example of Integer Data Type in Python

x=100
y=300
print("Integer Data Type:",(x+y))
print(type(x+y))
============OUTPUT============
Integer Data Type:400
<class 'int'>


Floating Data Type in Python

Floating Dats Type: A floating-point number consists of an integer part anda fractional part. In a program, these two parts are separated by a decimal point ().

Example of Float Data Type in Python

x=10.5
y=34.8
print("Float Data Type:",x+y)
print(type(x+y))
============OUTPUT============
Float Data Type:45.3
<class 'float'>


Complex Data Type in Python

Complex numbers: A complex number consists of a real part and an imaginary part. They are useful for a variety

of scientific and engineering calculations, such as signal processing, quantum mechanics, and many other areas. A complex number in Python can be created using (5+6j).

Example of Complex Data Type in Python

x=5
y=3j
print("Complex Data Type:",x+y)
print(type(x+y))
============OUTPUT============
Complex Data Type:(5+3j)
<class 'complex'>


Boolean Data Type in Python

Boolean values: Python also has a built-in Boolean data type called bool. A variable of type bool has two possible values: True and False, which are the integers1 and 0, respectively.

Example of Boolean Data Type in Python

x=True
print("Boolean Data Type:",x)
print(type(x))
============OUTPUT============
Boolean Data Type: True
<class 'bool'>


String Data Type in Python

Strings: A string in python is a sequence of one or more Unicode characters enclosed in single, double, or triple quotes. Python strings are immutable. 

This means that when you perform an operation on strings you always create a new string object of the same type rather than modifying an existing string.

Example of String Data Type in Python

name="Welcome To Jiocoding"
print("String Data Type:",name)
print(type(name))
============OUTPUT============
String Data Type: Welcome To Jiocoding
<class 'str'>


None Data Type in Python

None type: The None type in Python is a special object used to represent the absence of a value or empty. This type is used to indicate that a variable has no value or that a function returns nothing.

Example of None Data Type in Python

x=None
print("None Data Type:",x)
printf(type(x))
============OUTPUT============
Welcome To Jiocoding Website
<class 'NoneType'>

Advance Data Type in Python

Data Type Example
List data=[1,"Jiocoding"]
Tuple data=(1,"Jiocoding")
Dictionary data={"website","jiocoding"}
Set s={1,"jiocoding"}

List Data Type in Python 

List Data Type: List data type is a collection of data of different of data type. It can be used to store list of values. A list is created by using comma separated values between square brackets [].

List Data Type Python Example

list_data=["Python", "Java", "C++", "Jiocoding"]
print("List Data Type:",list_data)
print(type(list_data))
============OUTPUT============
List Data Type: ['Python', 'Java', 'C++', 'Jiocoding']
<class 'list'>


Tuple Data Type in Python

Tuple Data Type: Tuple data type is a collection of data of different data types. We can not change the value of tuples. It is used to store tuple of values. A tuple has been created using parentheses (). Tuple data type is immutable.

Example of Tuple Data Type in Python

tuple_data=("Python", "Java", "C++", "Jiocoding")
print("Tuple Data Type:",tuple_data)
print(type(list_data))
============OUTPUT============
Tuple Data Type: ('Python', 'Java', 'C++', 'Jiocoding')
<class 'tuple'>


Dictionary Data Type in Python

Dictionary Data Type: A dictionary Data type is an unordered collection of data of different data types. Dictionary value can be changed. A dictionary is created using curly brackets {}. Dictionary value can be stored in key value pairs.

Example of Dictionary Data Type in Python

dic_data={'name': 'Jiocoding', 'age': 30, 'city': 'Noida'}
print("Dictionary Data Type:",dic_data)
print(type(dic_data))
============OUTPUT============
Dictionary Data Type: {'name': 'Jiocoding', 'age': 30, 'city': 'Noida'}
<class 'dict'>


Set Data Type in Python

Set Data Type: A set Data type is a unordered collection of data of different data types. Set does not contain duplicate data. A Set value can not be fix index value. A set is created using curly brackets {}.

Example of Set Data Type in Python

x=100
set_data={100,200,300,400,500,600}
print("Set Data Type:",set_data)
print(type(se_data))
============OUTPUT============
Set Data Type: {400, 100, 500, 200, 600, 300}
<class 'set'>

Conclusion of Python Data Type

Conclusion: Data Type in a most important part of programming language but python is advanced programming it can be automatically detects data types. This is a all about python data types you can brief details advance data type next article. If your any query please contact me by email or comment.


Post a Comment

0 Comments