Page 122 - Computing E-Book Grade 7
P. 122
The City School 2021-2022
5.8. Python Numbers
There are three numeric types in Python:
• Integer: also known as int, is a whole number,
positive or negative, without decimals, of Python Numbers
unlimited length. x=1 #int
• float: also known as floating point number, is a y=2.8 #float
number, positive or negative, containing one or z=1j #complex
more decimals.
• complex: are written with a “j” as the imaginary
part
Variables of numeric types are created when we assign a value to them. To verify the
type of any object in Python, use the type() function. A sample code that determines
type is shown below:
Type Conversion
We can convert from one type to another with the int()and float() methods. A
sample code is shown below:
122

