Exponentiation !!
Besides addition, subtraction, multiplication, and division, Python also supports exponentiation, which is the raising of one number to the power of another. This operation is performed using two asterisks.>>> 2**5
32
>>> 9 ** (1/2)
3.0 Quotient & Remainder !!
To determine the quotient and remainder of a division, use the floor division and modulo operators, respectively.
Floor division is done using two forward slashes.
The modulo operator is carried out with a percent symbol (%).
These operators can be used with both floats and integers.
This code shows that 6 goes into 20 three times, and the remainder when 1.25 is divided by 0.5 is 0.25.>>> 20 // 6
3
>>> 1.25 % 0.5
0.25
In the example above, 20 % 6 will return 2, because 3*6+2 is equal to 20.You can chain exponentiations together. In other words, you can rise a number to multiple powers. For example, 2 3 2.
Comments
Post a Comment