Python Program To Demonstrate Various Datatype

Write Python code to demonstrate various datatypes

# WAP to Demonstrate Various Datatypes

# Integer
n1 = 123
# Float
n2 = 123.456
# Complex
n3 = 1 + 2j
# String
n4 = "Hello"
# List
n5 = [1, 2, 3]
# Set
n6 = {1, 2, 3}
# Tuple
n7 = (1, 2, 3)
# Dictionary
n8 = {"A": 1, "B": 2, "C": 4}

print(type(n1))
print(type(n2))
print(type(n3))
print(type(n4))
print(type(n5))
print(type(n6))
print(type(n7))
print(type(n8))

Output:

<class 'int'>
<class 'float'>
<class 'complex'>
<class 'str'>
<class 'list'>
<class 'set'>
<class 'tuple'>
<class 'dict'>

<< Previous | Next >>


Leave a Reply

Your email address will not be published.