Did I find the right examples for you? yes no

# ZeroDivisionError

All Samples(811)  |  Call(695)  |  Derive(116)  |  Import(0)
```Second argument to a division or modulo operation was zero.
```

```        def f():
try:
yield 1
raise ZeroDivisionError('')
except:
```
```                try:
yield 3
raise ZeroDivisionError('')
except:
yield 4
raise ZeroDivisionError('')
```
```                try:
yield 2
raise ZeroDivisionError()
#1/0
yield 3  # never get here
```

```    """
if denominator == 0:
raise ZeroDivisionError("Denominator can not be zero")
if cancel:
g = gcd( numerator, denominator )
```

```    mf.putq(4)
self.ev.run()
mf.set_exception(ZeroDivisionError())
f3.set_result(3)
self.ev.run()
```
```    f2.set_result(2)
mf.putq(f1)
f1.set_exception(ZeroDivisionError())
mf.putq(f2)
mf.putq(f3)
```
```    self.ev.run()
f3.set_exception(ZeroDivisionError())
qf.putq(f3)
self.ev.run()
```
```    self.ev.run()
f4.set_exception(ZeroDivisionError())
self.ev.run()
qf.putq(f4)
```
```    sqf.putq(f1)
sqf.complete()
f1.set_exception(ZeroDivisionError())
self.assertRaises(ZeroDivisionError, g1.get_result)

```

```    dist = distance(a,b) * distance(b,c)
if dist == 0: # SD 2010 - http://mgl.scripps.edu/forum/viewtopic.php?f=11&t=245&p=1882
raise ZeroDivisionError("Input used:", a, b, c)

cos_theta = ( (a[0] - b[0]) * (c[0] - b[0]) +
```

```        return llop.int_floordiv(Signed, x, y)
else:
raise ZeroDivisionError("integer division")

def uint_floordiv_zer(x, y):
```
```        return x / y
else:
raise ZeroDivisionError("unsigned integer division")

def llong_floordiv_zer(x, y):
```
```        return llop.llong_floordiv(SignedLongLong, x, y)
else:
raise ZeroDivisionError("integer division")

def ullong_floordiv_zer(x, y):
```
```        return llop.llong_floordiv(UnsignedLongLong, x, y)
else:
raise ZeroDivisionError("unsigned integer division")

```
```        return int_floordiv_ovf(x, y)
else:
raise ZeroDivisionError("integer division")

def int_mod_ovf(x, y):
```

```                    N1 = N.gcd(Integer(2*y1 + a1*x1 + a3))
N2 = N//N1
raise ZeroDivisionError("Inverse of %s does not exist (characteristic = %s = %s*%s)" % (2*y1 + a1*x1 + a3, N, N1, N2))
else:
raise ZeroDivisionError("Inverse of %s does not exist" % (2*y1 + a1*x1 + a3))
```
```                    N1 = N.gcd(Integer(x1-x2))
N2 = N//N1
raise ZeroDivisionError("Inverse of %s does not exist (characteristic = %s = %s*%s)" % (x1-x2, N, N1, N2))
else:
raise ZeroDivisionError("Inverse of %s does not exist" % (x1-x2))
```

```        return llop.int_floordiv(Signed, x, y)
else:
raise ZeroDivisionError("integer division")

def uint_floordiv_zer(x, y):
```
```        return x / y
else:
raise ZeroDivisionError("unsigned integer division")

def llong_floordiv_zer(x, y):
```
```        return llop.llong_floordiv(SignedLongLong, x, y)
else:
raise ZeroDivisionError("integer division")

def ullong_floordiv_zer(x, y):
```
```        return llop.llong_floordiv(UnsignedLongLong, x, y)
else:
raise ZeroDivisionError("unsigned integer division")

```
```        return int_floordiv_ovf(x, y)
else:
raise ZeroDivisionError("integer division")

def int_mod_ovf(x, y):
```

```                    def __div__(self,x):
if x == 0:
raise ZeroDivisionError('float division')
elif x < 0:
return neginf
```
```                    def __divmod__(self,x):
if x == 0:
raise ZeroDivisionError('float divmod()')
elif x < 0:
return (nan,nan)
```
```                    def __mod__(self,x):
if x == 0:
raise ZeroDivisionError('float modulo')
else:
return nan
```
```                    def __div__(self,x):
if x == 0:
raise ZeroDivisionError('float division')
elif x < 0:
return inf
```
```                    def __divmod__(self,x):
if x == 0:
raise ZeroDivisionError('float divmod()')
elif x < 0:
return (nan,nan)
```

```    def __floordiv__(self, other):
if isinstance(other, (int, long)):
if other == 0:
raise ZeroDivisionError('mpz division by zero')
res = _new_mpz()
```
```        elif isinstance(other, mpz):
if other == 0:
raise ZeroDivisionError('mpz division by zero')
res = _new_mpz()
gmp.mpz_fdiv_q(res, self._mpz, other._mpz)
```
```    def __rfloordiv__(self, other):
if isinstance(other, (int, long)):
if self == 0:
raise ZeroDivisionError('mpz division by zero')
res = _new_mpz()
```
```    def __mod__(self, other):
if isinstance(other, (int, long)):
if other == 0:
raise ZeroDivisionError('mpz modulo by zero')
r = _new_mpz()
```
```        elif isinstance(other, mpz):
if other == 0:
raise ZeroDivisionError('mpz modulo by zero')
r = _new_mpz()
gmp.mpz_fdiv_r(r, self._mpz, other._mpz)
```

```			put = max(0.0, self.strikePrice - self.underlyingPrice)
if self.strikePrice == 0:
raise ZeroDivisionError('The strike price cannot be zero')
else:
call = e**(-self.foreignRate * self.daysToExpiration) * \
```
```			put = -1.0 if self.underlyingPrice < self.strikePrice else 0.0
if self.strikePrice == 0:
raise ZeroDivisionError('The strike price cannot be zero')
else:
_b_ = e**-(self.foreignRate * self.daysToExpiration)
```
```			put = 1.0 if self.underlyingPrice < self.strikePrice else 0.0
if self.strikePrice == 0:
raise ZeroDivisionError('The strike price cannot be zero')
else:
_b_ = e**-(self.domesticRate * self.daysToExpiration)
```
```			return 0.0
if self.strikePrice == 0:
raise ZeroDivisionError('The strike price cannot be zero')
else:
return self.underlyingPrice * e**-(self.foreignRate * \
```
```			put = max(0.0, self.strikePrice - self.underlyingPrice)
if self.strikePrice == 0:
raise ZeroDivisionError('The strike price cannot be zero')
else:
call = self.underlyingPrice * norm.cdf(self._d1_) - \
```

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next