August 2019
Beginner
482 pages
12h 56m
English
Floats and integers represent rational numbers with and without a decimal part, respectively. Those types are quite intuitive to use, as they can be added, subtracted, multiplied, divided, and more. Let's take a look at the following example. First, we assign two variables:
A = 6B = 5
Now, let's go over some possible operations:
>>> A + B11>>> A - B1>>> A / B1.2>>> A * B30
You can also raise numbers to a power by using double asterisks:
>>> 2**38>>> 3**29
You might have noticed that the division of two integers will result in a float. This happens even if the remainder is zero:
>>> 10 / 25.0
If you need to keep the integer division result as an integer (rounded, if needed), then use a double slash instead; this operation ...