Skip to content

Commit 694ee06

Browse files
authored
Merge pull request #111 from UoMResearchIT/109-correct-calculation-in-units-and-quantities
109 correct calculation in units and quantities
2 parents 33cf6a0 + b17e59e commit 694ee06

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

episodes/05-units_and_quantities.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ This enables the use of arithmetic operations when quantities have compatible un
104104

105105
```python
106106
distance_start = 10 * u.mm
107-
distance_end = 23 * u.km
107+
distance_end = 20 * u.km
108108
length = distance_end - distance_start
109109
print(length)
110110
```
@@ -349,6 +349,8 @@ angle in degrees: 90.0; and in radians: 1.5707963267948966
349349
Now we can pass the angle directly to `np.sin` without having to convert directly to radians:
350350

351351
```python
352+
import numpy as np
353+
352354
print(f'sin of 90 degrees is: {np.sin(angle)}')
353355
print(f'sin of pi/2 radians is: {np.sin(1.57079632)}')
354356
print(f'sin of 90 degrees is not: {np.sin(90)}')
@@ -376,7 +378,10 @@ angles = np.arange(181) * u.deg
376378
```
377379

378380
```python
381+
import matplotlib.pyplot as plt
382+
379383
plt.plot(angles, np.sin(angles))
384+
plt.show()
380385
```
381386

382387
![](fig/sin_curve_deg.png){alt='Plot of sin curve for degrees between 0-180'}

0 commit comments

Comments
 (0)