Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. import numpy as np
  2. import scipy as sp
  3. import matplotlib.pyplot as plt
  4.  
  5. def wartosc(f,x):
  6. return eval(f,{'x':x})
  7.  
  8. print('funkcja y=a*x+b')
  9. a= input('Podaj a=')
  10. b= input('Podaj b=')
  11. funkcja=a+"*x+" +b
  12. xmin=-1
  13. xmax=1
  14. x=np.arange(xmin,xmax,0.1)
  15. y=x+0.0
  16. for i in range(0,len(x)):
  17. y[i]=wartosc(funkcja,x[i])+sp.rand()
  18.  
  19. plt.plot(x,y,"ro", ms = 5)
  20. plt.title("y="+funkcja)
  21. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement