In [23]:

```
import sys
sys.float_info.epsilon
```

Out[23]:

2.220446049250313e-16

In [6]:

```
0.3**2 == 0.09
```

Out[6]:

True

In [5]:

```
0.2**2 == 0.04
```

Out[5]:

False

In [8]:

```
import numpy as np
np.isclose((0.2)**2, 0.04)
```

Out[8]:

True

In [8]:

```
print(sys.float_info.min, sys.float_info.max)
```

2.2250738585072014e-308 1.7976931348623157e+308

In numpy, results that are larger than the maximum range a set to `inf`

or `-inf`

, respectively.

In [29]:

```
a = np.exp(1000)
print(a)
```

inf

<ipython-input-29-7891d9d166db>:1: RuntimeWarning: overflow encountered in exp a = np.exp(1000)

Undefined operations result in the floating point value `nan`

In [9]:

```
print(np.sqrt(-1), np.log(-1), np.arcsin(1.1))
```

nan nan nan

<ipython-input-9-e46aa987836e>:1: RuntimeWarning: invalid value encountered in sqrt print(np.sqrt(-1), np.log(-1), np.arcsin(1.1)) <ipython-input-9-e46aa987836e>:1: RuntimeWarning: invalid value encountered in log print(np.sqrt(-1), np.log(-1), np.arcsin(1.1)) <ipython-input-9-e46aa987836e>:1: RuntimeWarning: invalid value encountered in arcsin print(np.sqrt(-1), np.log(-1), np.arcsin(1.1))

A key issue in large software project is to manage complexity. The total cost have of having a mess can be large in terms of wasted time and money. From Robert C. Martin books Clean code: "As the mess builds, the productivity of the team continues to decrease, asymptotically approaching zero".

A few simple rule might help. The text below was adapted from

- Function bodies should be short — hardly ever longer than 20 lines and mostly less than 10 lines
- Functions should take as few arguments as possible

"Clear and expressive code with few comments is far superior to cluttered and complex code with lots of comments. — Robert C. Martin

Not so clear:

```
// Check to see if the employee is eligible for full benefits
if ((employee.flags & HOURLY_FLAG) &&
(employee.age > 65))
```

Better:

```
if (employee.isEligibleForFullBenefits())
```

- Example:
`int elapsedTimeInDay`

is better than`int days`

- Function names should say what they do

"Unit tests are typically automated tests written and run by software developers to ensure that a section of an application (known as the "unit") meets its design and behaves as intended." (from the wikipedia article on unit testing)

- Beautiful is better than ugly.
- Simple is better than complex.
- Readability counts.

(Try `import this`

)

In [1]:

```
import this
```

In [ ]:

```
```