Advertisement
Korotkodul

сопротивление

Nov 7th, 2024
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. import math
  2.  
  3. Y = [44.22, 60.87, 77.74, 94.62, 111.34, 128.43, 145.12, 161.96, 178.79, 195.6]
  4. X = [10, 14, 18, 22, 26, 30, 34, 38, 42, 46]
  5. n = 10
  6. xy = 0
  7. x = 0
  8. y = 0
  9. x2 = 0
  10. for i in range(10):
  11.     x += X[i]
  12.     y += Y[i]
  13.     xy += X[i] * Y[i]
  14.     x2 += X[i]**2
  15. x /= n
  16. y /= n
  17. xy /= n
  18. x2 /= n
  19. k = round((xy - x * y) / (x2 - x ** 2), 2)
  20. b = round(y - k * x, 2)
  21.  
  22. print("k b ", k, b)
  23.  
  24. def f(x):
  25.     return k * x + b
  26.  
  27. for i in range(10):
  28.     print(i, f(X[i]))
  29.  
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement