Advertisement
jukaukor

easter.py

Apr 17th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. # Python-ohjelma laskee Pääsiäisen ajankohdan
  2. # Juhani Kaukoranta
  3.  
  4. import math
  5.  
  6. print("Lasketaan Pääsiäisen ajankohta haluttuna vuotena")
  7. vuosi = int(input("Anna Pääsiäisen vuosi "))
  8.  
  9. def easter1(year):
  10. # Catholic, Protestant and Finnish Orthodox Easter
  11. a = year % 19
  12. b = math.floor(year/100)
  13. c =year % 100
  14. d = math.floor(b/4)
  15. e = b % 4
  16. f = math.floor((b+8)/25)
  17. g = math.floor((b-f+1)/3)
  18. h = (19*a+b-d-g+15) % 30
  19. i = math.floor(c/4)
  20. k = c % 4
  21. l = (32+2*e+2*i-h-k) % 7
  22. m = math.floor((a+11*h+22*l)/451)
  23. n = math.floor((h+l-7*m+114)/31)
  24. p = (h+l-7*m+114) % 31
  25. month1 = n
  26. day1 = p+1
  27. print("Katolisten, protestanttien ja Suomen ortodoksien Pääsiäisen päivämäärä:")
  28. print(day1,".",month1,".",year)
  29.  
  30. def easter2(year):
  31. # Othodox Church's Easter, except Finnish, according Gregorian calendar
  32. a = year % 4
  33. b = year % 7
  34. c = year % 19
  35. d = (19*c+15) % 30
  36. e = (2*a+4*b-d+34) % 7
  37. month2 = math.floor((d+e+114)/31)
  38. day2 = (d+e+114) % 31 + 1 + 13
  39. # 13 päivää lisättävä Juliaaniseen kalenteripäivään
  40. # koska itäinen kirkko käyttää Gregoriaanista kalenteria
  41. if (day2 > 31 and month2 == 3):
  42. month2 = month2 + 1
  43. day2 = day2 - 31
  44. if (day2 > 30 and month2 == 4):
  45. month2 = month2 + 1
  46. day2 = day2 - 30
  47. print("Muiden ortodoksien,paitsi Suomen, Pääsiäinen Gregoriaanisen kalenterin mukaan")
  48. print(day2,".",month2,".",year)
  49.  
  50. easter1(vuosi)
  51. easter2(vuosi)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement