SHOW:
|
|
- or go back to the newest paste.
| 1 | - | #import numpy as np |
| 1 | + | import numpy as np |
| 2 | import matplotlib.pyplot as plt | |
| 3 | #Funksjon som gir hvor mange prosent som er igjen av stoffet. | |
| 4 | def p(t,h): | |
| 5 | return 0.5**(t/h)*100 | |
| 6 | ||
| 7 | #Be om verdier for t og h. | |
| 8 | t = np.linspace(0, float(input("Hvor lang tid skal gå? ")), 1000)
| |
| 9 | h = float(input("Hva er halveringstiden? "))
| |
| 10 | ||
| 11 | #Lage graf. | |
| 12 | fig = plt.figure() | |
| 13 | ax1 = fig.add_subplot(111) | |
| 14 | ax1.grid(True) | |
| 15 | ||
| 16 | x = t | |
| 17 | y = p(t,h) | |
| 18 | ||
| 19 | ax1.plot(x,y) | |
| 20 | plt.show() |