DAY 2:
In this blog, you will get to know about the basic data types of python.
DATA TYPES
There are different types of in-built data types in python. We will discuss it with examples.
DATA TYPES IN PYTHON:
Numeric
Boolean
Sequential
Dictionary
Set
Numeric -
Numeric data types in python define a numerical class.
Integer
Float
Complex
Integer
n=45
print(type(n))
output :
Float
n=5.01
print(type(n))
output :
Complex
n=5.01+1j
print(type(n))
output :
These are the numeric data types in python.
Boolean
Boolean data types are whether the object is true or false.
print(type(True))
output :
print(type(False))
output:
It is very important, to write the first letter of "True" in capital "T", and "False" in capital "F", otherwise you may get an error.
Sequential
Sequential data types are the ordered collection of data items.
String
List
Tuple
String
- Collection of characters
s=str(input("Enter the name : "))
print(s)
print(type(s))
output :
Enter the name : Priya
Priya
<class 'str'>
List
- Collection of data
l=[2,4,5,2]
print(l)
print(type(l))
output :
Tuple
- ordered collection of data
t=(4,6,2,4)
print(t)
print(type(t))
output :
Dictionary
- An unordered collection of data has a "Key" and "Value", the key is immutable whereas the value is mutable.
l={1:'Me',2:'You',3:'Us'}
print(l)
print(type(l))
output :
Set
The set is an unordered collection of data that is mutable, iterable and has no duplicate items.
l={2,3,4,2,3,6,7,8,4} print(l) print(type(l))
output :
These are the data types ,or in-built data types of python programming.
For your reference :
DATA TYPES | IMMUTABLE | MUTABLE |
Numeric | ✅ | ❌ |
List | ❌ | ✅ |
String | ✅ | ❌ |
Dictionary | ❌ | ✅ |
Tuple | ✅ | ❌ |
Set | ❌ | ✅ |
In my next blog ,you will get to know more about this data types in details.
Thank you.