Datatypes:
15 September 2025 17:28
Definition of Data: Data is a collection of information that can store by program and we can manipulate it.
Data is any value that assigned to a variable.
Definition of Datatypes: Datatypes in python defines the kind or category of data that variable can hold and determines what
operation can be performed on that data.
Why Datatypes are needed?
it is needed for multi value datatypes we have.
To check type of data we use Type() function.
Types of datatypes:
According to the value we can store inside of a variable we can divide it into 2 types.
1. Single value Datatypes/Individual datatypes.
• Numeric:
a. Integer
b. Float
c. complex
• Boolean
i) True.
ii) False.
[Link] value Datatypes/Collection Datatypes.
• String
• List
• Tuple
• Set
• Dictionary
Default value:
It is the vale that python automatically assigns to a variable, datatype or function when no specific value is given.
• Default value depend on the datatypes.
• To check default value => datatype()
Example: >>>int()
Ans: 0
>>>Str()
Ans: ''
Non-default value:
A non-default value is when user assigns a value different from the default.
How to check the value is default or not?
By using bool()=> if the bool function gives true it is a non - default value ,and if it gives you False the value is default.
Example:
>>>a='Rajat'
>>>Bool(a)
Ans: True
>>>b=0
>>>Bool(b)
Ans: False
Mutable Datatypes:
Mutable data types can be changed or modified after they are created. if user modify it will be modified inside the previous
address
Example: list, set, dictionary
Immutable Datatypes:
Immutable data types cannot be changed after they are created. Any operation that tries to modify them will instead create a new
address.
Example:
Int, float, string, complex, tuple.
1. Integer Datatypes:
Definition: it is a whole number that doesn't consist any decimal point.
• It is immutable datatype.
New Section 9 Page 1
• It is immutable datatype.
• It can be +ve,-ve,0 also.
Example:
a=10
b=-3
c=0
To check the type : type(a)=> int.
Default value of int=> int()=0
Memory allocation :
Same like variable.
2. Float datatypes:
Definition: it is a whole number that consist decimal point.
• It is a immutable datatype.
• It can be +ve,-ve.
Example:
a=12.5
b=-14.5
To check the type: type(a) => float.
Default value of float => float()= 0.0
Memory allocation :
Same like integers.
3. Complex datatypes:
Definition: it a datatype which consist of 1 real part and 1 imaginary part.
• Syntax: (real part)+(imaginary part)
(a+bj)[ here a is real part and bj is imaginary part]
This j can be in capital also
We can write like (a+jb) and (bj+a) also but I can't be (jb+a).
Example:
a=2+3j or 3-7j
b=5+7J or 5-7J
c=8j+3 or 6j-4
Default value of complex=> complex()=0j
To check the type of complex=> type(a)=complex.
Memory allocation:
Boolean datatype: These are the datatype as also as the keywords.
We can use boolean to check the conditions and to check the default
value or not also.
There are 2 values in boolean-> 1. True. 2. False.
Example:
Bool(32)=> True
Bool(0)=>False
32>22=> True
13>18=>False
New Section 9 Page 2