Python Programming...Need some help!!!

page: 1
0

log in

join

posted on May, 11 2004 @ 12:00 AM
link   
I need some serious help with a computer science class. Here's my dilemma...

The sylabus originally stated that our final project (well not final project because this assignment should be ridiculously easy..) was originally supposed to be some basic coding and such with flash. I happen to be very proficient with flash (hence my taking this course as one of my easy ones.) However, unbeknownst to me until about a week ago, they changed the last project to making a simple program in Python (when I say simple I mean it should be a cake walk for anyone with basic knowledge of the language...see assignment below.) Because I was under the assumption that we were going to be doing flash, I didn't go to class and have now missed the steps and general knowledge required to complete the assignment. I know I could probably figure this thing out eventually, however, its due tomorrow by midnight and I have neither the time nor the energy to deal with this as I have another exam tomorrow that requires my utmost attention to prepare for. I was wondering if anyone could help me out. Heres the assignment and also some other stuff they gave us to get started.

----------------------------------------------------------------------
As a matter of National security, we want to know when head TA Mike Viamari’s birthday and Easter occur on the same day: March 31st.

Your mission is to write a short program that tells us which years between 1900 and 2099 Easter falls on the 31st.

You will be supplied with a function called easterday(year). The value of the variable ‘year’ is calculated into the day of the month that Easter falls on for that year.

A value between 1 and 31 is returned when the function is given with a year between 1900 and 2099
-------------------------------------------------------------------
Heres the function easterDay they gave us:
--------------
def easterDay(year):

if year < 1900 or year > 2099:
raise ValueError, 'easterDay is only valid from 1900 to 2099'
year = int(year)

a = year%19
b = year%4
c = year%7
s = 19*a + 24
d = s%30
t = 2*b + 4*c + 6*d + 5
e = t%7
theDay = 22 + d + e
if theDay >= 32:
theDay = d + e - 9

elif theDay == 26:
theDay = 19


elif theDay == 25 and a == 16 and d == 28:
theDay = 18

return (theDay)
----------------
Basically I got the thing to work if I specify a specific year and it will spit out whether easter falls on the 31st for that year or not but where I'm stuck is getting the program to run through all the years automatically and spit out which particular years Easter falls on the 31st.

Much appreciation for anyone who can help me out of this small pickle.

Thanks

[Edited on 11-5-2004 by hopblaze]




posted on May, 11 2004 @ 01:25 PM
link   
Not sure if I am reading the question correct, but my answer would be this:

theYear = 0
for year in range(1900, 2099):
theYear = easterDay(year)
print theYear

I may have mis-understood the question, if I have - sorry. One comment though, if I did understand the question correctly, and my answer above is good for you - what the heck are you doing in a computer science scall when you can't work that out?



posted on May, 11 2004 @ 01:28 PM
link   
sorry, ATS gets rid of tabs, so the code won't compile like that - u should know what tabs to put in, lol



posted on May, 11 2004 @ 01:32 PM
link   
Or, to make it look better: (again, tabs are disposed off, so try and put the tabs in the right place):

theYear = 0
for year in range(1900, 2099):
theYear = easterDay(year)
print "year :" + theYear





new topics
 
0

log in

join