# [ACCEPTED]-python logarithm-python

You can only compute the logarithm of a 8 positive number. Trying to compute the logarithm 7 for a negative number or zero will result 6 in a "math domain error" in Python.

By the 5 way: it looks like you're actually trying 4 to compute a logarithm base 2. You can do 3 this with `math.log`

:

```
w=math.log(q*q1, 2)
```

The second, optional, parameter 2 is the base. It defaults to e (ie: natural 1 log).

Is q or q1 equal to zero or one of them 1 negative?

try to make sure the value whose log you 4 are trying to find can never be 0. As log(0) tends 3 to negative infinity, the function call 2 will give you a math domain error. Correct 1 that and I think you'll be fine.

More Related questions

We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.