from math import sqrt

X = 2

Y = 4

print(“The product of “, x, “and”, y, “is”, x + y)

print(“The root of their difference is “, sqrt(x – y))

# Find two run-time errors:

**mtf**#2

There’s two, already. Python is case sensitive.

Product?

```
>>> from math import sqrt
>>> sqrt(-1)
Traceback (most recent call last):
File "<pyshell#116>", line 1, in <module>
sqrt(-1)
ValueError: math domain error
>>>
```

**mtf**#3

Interestingly enough if we use fractional exponents on a negative number we get returned that number…

```
>>> -1 ** 0.5
-1.0
>>> -1 ** 1.5
-1.0
>>>
```

The lesson here is that if you depend upon your code returning the correct result (or an exception) use the `math`

module’s `sqrt`

class.

**system**#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.