- ZeroDivisionError
1 Excel[ | ]
PHP
Copy
=2/0
- →
#DIV/0!
2 PHP[ | ]
PHP
Copy
$a = 1 / 0;
// PHP Warning: Division by zero
3 Python[ | ]
Python
Copy
result = 5 / 0
# ZeroDivisionError: division by zero
Python
Copy
def divide(a, b):
try:
result = a / b
except ZeroDivisionError:
return False
return result
print( divide( 4, 2 ) )
print( divide( 4, 0 ) )
# 2.0
# False