In Python variables are dynamic data types. Means variable declare it’s types based on values stored. |
Type | Description | Examples |
---|---|---|
int | Whole numbers | a = 20 |
float | Numbers with decimal | a = 20.3 |
str | Sequence of character | a = "Hello" a = 'HI' |
list | Ordered sequence of character - It can be mixed | a = [10,20,"Hello",89.23] |
dict | Unordered Key value pairs | {"key1":"value1","key2":"value2"} |
tuple | Ordered immutable sequence of objects | (10,"hello",23.56) |
set | Unordered collection of unique objects | a = {"a","b"} |
boolean | Indicate True or false | a = 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.