-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformule-gebroken.py
26 lines (26 loc) · 1005 Bytes
/
formule-gebroken.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import numpy as np
from math import *
from tabel import raster as tabel
class formules():
def __init__(self, start=0, stop=1, steps=1, formula=input('f(x) = ')):
self.start = float(start)
self.stop = float(stop)
self.steps = float(steps)
self.stop += self.steps
self.formula = formula
self.dict = {}
for a in list(np.arange(step=self.steps, start=self.start, stop=self.stop)):
formula2 = self.formula[::1]
exec(f'try:\n self.y = {formula2.replace("x", str(a))}\nexcept:\n self.y = inf')
self.dict[float(a)] = float(self.y)
def get(self):
return self.dict
if __name__ == '__main__':
coords = formules(start=input('start = '), stop=input('stop = '), steps=input('steps = ')).get()
first = list(coords.keys())
first.insert(0, 'y ')
second = list(coords.values())
second.insert(0, 'x ')
tb = tabel(first, '|')
tb.append(second)
tb.build()