Posts Python Datatypes
Post
Cancel

Python Datatypes

In Python variables are dynamic data types. Means variable declare it’s types based on values stored.
TypeDescriptionExamples
intWhole numbersa = 20
floatNumbers with decimala = 20.3
strSequence of charactera = "Hello"
a = 'HI'
listOrdered sequence of character - It can be mixeda = [10,20,"Hello",89.23]
dictUnordered Key value pairs{"key1":"value1","key2":"value2"}
tupleOrdered immutable sequence of objects(10,"hello",23.56)
setUnordered collection of unique objectsa = {"a","b"}
booleanIndicate True or falsea = True
b = False


❗❗ List and Tuple looks same but List is mutable means the value of list can be modified post creation. Where as Tuple once declared can’t be modified.

💁 To know what type the variable use type()

Example:

1
2
3
4
5
6
7
8
9
>>> a = 1
>>> b = 2.0
>>> c = "Hi"
>>> type(a)
<class 'int'>
>>> type(b)
<class 'float'>
>>> type(c)
<class 'str'>

Thanks for reading till end.

Followus on @techpechu

Join Our Discord

We do run a youtube channel in Indian regional language Tamil called TechPechu. Do subscribe us for moral support. Happy Learning.

Follow us on instagram @techpechu