Data Types – Numbers
- Integers, Floats, Complex
- V VIDYASHANKAR
- 6 T H JULY 2O25
Integers
Numbers are often used in programming to keep score in games, represent data
visualizations,
store information in web applications
The usual operations of addition ( + ), subtraction ( - ), multiplication ( * ) and
division ( / ) are
possible in Python
Integers can be positive or negative
Example
Example
Float
A float or a floating point number is positive, or negative containing a decimal
point
All the usual operations that are applicable to integers are applicable to floats as
well
Float is useful in mathematical programs where precision in numerical
calculation becomes
important
Example
Example
Complex Numbers
A complex number has a real part and imaginary part
In mathematical terms, it is written as a + i b where a is the real part and b is the
imaginary part
For example : 3 + 4 i
In Python, a complex number is represented by 3 + 4 j
The usual operations of addition, subtraction, multiplication and division can be performed
on
Complex Numbers
Example
Do-it-yourself
Check if Python accepts i as an imaginary number
Look at exploring possible combinations : Integer + float, Float – Integer, Integer / Float, Float / Integer
And Integer * Float and Float * Integer