Home >>Python Tutorial >The Python Numbers Exercises
In this lesson of the Python numbers tutorial, we will be talking about the particular section of numbers in Python. And to start this part of the tutorial it is first important for you to know that there are basically three different types of numeric types in Python.
And those three types of numeric in Python are mentioned below.
You should also be aware of the fact that the various variables for the numeric types are assigned in this programming language within the second when you actually assign a value to them.
For example
x = 1 # int y = 3.8 # float z = 1j # complex
Also, if you wish to verify the different kinds of object or the types of any object in this programming language then you just need to use the function of type(). Using this function will enable you to view the type of an object that you might be using as a developer in Python.
One of the Python numbers exercises are
print ( type (x) ) print ( type (y) ) print ( type (z) )
The int here actually stands for the integer that you might be using as a developer in this programming language. The integer or the int can be defined as a kind of a whole number, any kind of positive or negative number, or any number without some kind of decimal, and of unlimited length.
The Python print integer example is
x = 1 y = 3565289465246 z = -3244488 print ( type (x) ) print ( type (y) ) print ( type (z) )
The float is also known as the floating point number. And this float or floating point number can be defined as a kind of number that can be either positive or negative and it further must contain one or more number of decimals in it.
For example
x = 1.10 y = 1.0< z = -35.49 print ( type (x) ) print ( type (y) ) print ( type (z) )
This can be treated as a type of Python numbers exercises. It is also important for you to remember that a float or the floating point number can also be described as a type of scientific number that begins with an ‘e’. This ‘e’ in the scientific number is used to indicate or point to a power of 10.
For example
x = 35e3 y = 12E4 z = -87.7e100 print ( type (x) ) print ( type (y) ) print ( type (z) )
These complexes are also a type of numeric that is used in this programming language. And if you wish to use these number types then it is important for you to remember that these numeric types are used with a ‘j’ as the part of the imaginary.
For example
x = 3+6j y = 6j z = -6j print ( type (x) ) print ( type (y) ) print ( type (z) )
With this, we finish the numbers part of our python tutorial which included Python float numbers, integers, and complexes.