Advertisement
jukaukor

easter

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