Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. import math
  2. import random
  3.  
  4. def calcv(latitud,t):
  5. return (23.5*math.sin(math.pi*(t-80)/180)+90-latitud)/90
  6.  
  7. def decide(v):
  8. if 0<v<1:
  9. return v**2
  10. if v>=1:
  11. return 1
  12. if v<=0:
  13. return 0
  14.  
  15. def calcenergy(f):
  16. return area*f*sundigit*random.random()
  17.  
  18. area=500
  19. sundigit=10
  20. t=int(input("How many latitudes do you want to calculate?"))
  21.  
  22. x=0
  23. listalatitud=[]
  24. while x<t:
  25. latitud=int(input("latitud"))
  26. if latitud>0 and latitud<90:
  27. listalatitud.append(latitud)
  28. x=x+1
  29. else:
  30. print("Next time say a latitude between 0 and 90")
  31.  
  32. lista=[]
  33. total=0
  34. for latitud in listalatitud:
  35. tmp = []
  36. for t in xrange(365):
  37. v=calcv(latitud,t)
  38. f=decide(v)
  39. l=calcenergy(f)
  40. tmp.append(l)
  41. lista.append(tmp)
  42.  
  43. for i in lista:
  44. print "Year average", sum(i) / float(len(i))
  45.  
  46. average = [sum(i) / float(len(i)) for i in lista]
  47. average.sort()
  48. print average
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement