Lesson 2. Integer and float numbers
1/10. Integer arithmetics
We already know the following operations which may be applied to numbers:+
, -
, *
and **
. The division
/
always gives you a float (a floating-point real number, an object of type float
).From high school, you probably remember how to calculate negative powers. We want to provide an example if you don't remember: 2-3 = 1 / ( 23 ) = 0.125. Of course, Python allows you to calculate negative powers just the same way as positive ones:
print(2 ** -3)
.The exponentiation
**
also returns a float when the power is negative.
Instructions
Click "Run" to see what happens in output!
print(17 / 3) print(20 / 4) print(2 ** 4) print(2 ** -3)