Page 1 of 1

The code is correct, but the execution is faulty

Posted: Thu Jul 29, 2021 8:53 am
by Jackli
The following code I wrote without an error being reported, but when it was executed an error occurred.

Code: Select all

>>> a = 10/0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ZeroDivisionError: division by zero

Re: The code is correct, but the execution is faulty

Posted: Thu Jul 29, 2021 9:16 am
by stijn
What would you expect the result to be? It's pretty much undefined, hence the error.. https://en.wikipedia.org/wiki/Division_by_zero

Re: The code is correct, but the execution is faulty

Posted: Sat Jul 31, 2021 4:47 pm
by williamhenrick
obviously it will give the error, btw check 20/0, that will also give the error. :D