+ 1
What if we want the quotient and remainder of divide to be float? // And % doesn't give it in float form....
QUOTIENT IN FLOAT
2 ответов
+ 3
You can python ask to return a number as a float by using float()
The output of print(float(10%3)) is 1.0
+ 1
Depends on the language. But in general there are two options. If you want to calculate an integer A modulo an integer B, then the integer division // and modulo will return integers. These integers can be type casted to float.
Secondary, if you want to calculate a float A modulo a float B/Integer B, the integer division and the modulo operator will not work.
@Sebastian This is the same you suggested, but I kept the concept of Type Casts more in general. But you did a good example at this point.