Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. import math as m
  2. from matplotlib import pyplot as plt
  3.  
  4. th0 = float(raw_input())
  5. l=float(raw_input())
  6.  
  7. g=9.807
  8. print l
  9. print th0
  10.  
  11.  
  12. def wi(wold,ths,dt) : return wold - (g/l)*m.sin(ths*(m.pi/180))*dt
  13. def thi(thold, wold, dt) : return thold + wold*dt
  14.  
  15. print wi(0,th0,0.1)
  16. thetas=[]
  17. omegas=[]
  18.  
  19. w=0
  20. th=th0
  21. for i in range(20):
  22.     thetas.append(th)
  23.     w=wi(w,th,0.1)
  24.     th=(th,w,0.1)
  25.  
  26. w = 0
  27. th = th0
  28. for i in range(20):
  29.     omegas.append(w)
  30.     w=wi(w,th,0.01)
  31.     th=(th,w,0.01)
  32.  
  33. print thetas
  34. print omegas
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42. 60
  43. 0.5
  44. Traceback (most recent call last):
  45.   File "/Users/abcd/Desktop/odev2.py", line 23, in <module>
  46.     w=wi(w,th,0.1)
  47.   File "/Users/abcd/Desktop/odev2.py", line 12, in wi
  48.     def wi(wold,ths,dt) : return wold - (g/l)*m.sin(ths*(m.pi/180))*dt
  49. 0.5
  50. 60.0
  51. TypeError: can't multiply sequence by non-int of type 'float'
  52. -1.69862222698
  53.  
  54. Process finished with exit code 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement