Hello, I wrote the code below when I made the coin calculation program.
a, b, c = map(int, input().split())
result = a * 10 + b * 50 + c * 100
print(result)
However, I wonder why integer divided by 0
is an error and integer multiplied by 0
is executed without error.
For example, 5 divided by 0
is mathematically 5 divided by 0/0
and the reciprocal is used to change it to 5 divided by 0/0
, so I think it is the same as 5 * 0
. Or do you get a reflexive error if you recognize 0 divided by?
Yes. The 0 division error is a very mechanical grammatical error. 5/0 = (5*0)/0
so you might think that it should be executed without a problem, but it's not that dimension. As soon as the number/0
appears, the interpreting/compiling step will fail.
That's because... The common explanation is that 5/0
is the number of times you can subtract 0 from 5, so no answer is correct. x*0=5
in the process of obtaining the inverse of the multiplication called 5/0
. For this award, we will promise professional explanations from those who have studied university mathematics...
In any case, most programming languages reject this operation because it is an operation that does not work in the first place. When implementing a division that allows users to arbitrarily specify divisors, it is recommended to remember that divisors!= 0
processing must be done unconditionally.
It is clear why + integer times 0 is possible. +5 is equal to zero because it's zero. If there are 5 apples in the warehouse that I just built, and there are 0 boxes, how many apples are there in the warehouse? I have something to say.
There is an error in the logic you deployed.
0 is not 0/0. 0/1 or 0/2 or 0/3.
Therefore, dividing by zero and multiplying by zero is different. It's very different.
© 2024 OneMinuteCode. All rights reserved.