+ 2

Why learn division % if Decimal Module?

If a cheap, handheld calculator can figure out integer and floating point division with '/', I can't get past why Python 3.6 requires the programmer to use 2 different division operators--one for integer and one for floating point? Is there a good reason why 'I' as a rank beginner should struggle with '/', '//' and '%' if there exists (from what I just read) a decimal library that lets you do division as do calculators and people of the real world doing everyday math? Mark

3rd May 2019, 8:15 PM
Mark
3 Réponses
+ 8
Sometimes computer programs need integer values and sometimes they need floating point values.
4th May 2019, 12:24 AM
Sonic
Sonic - avatar
0
<<programs need integer values and sometimes they need floating point>>> I think I get that. What I know I don't get is why the interpreter cannot obtain the integer/float information from the input form--just as a calculator would. If I knew the program needed float then I'd enter 5.0 instead of 5. If I enter any decimal or exponent or...then I would expect the interpreter to know the program wants float. If I enter 5/2 I would expect the interpreter to realize there's a remainder and provide the decimal answer--in one step. Then although the divisor and dividend were integers, the interpreter would have to provide a decimal float quotient, otherwise the math would be incorrect. Can you see where my thought process is missing the boat?
4th May 2019, 9:27 PM
Mark
0
It's the feature on most programming language
6th May 2019, 8:50 AM
Erwin Ansory