I have written other programs for the assignment. Here is a program that I just did so far for and it runs and works correctly. I have very little knowledge of computer science because I am an education major in a room filled with computer science majors. However, I have yet to figure out the problem that I have been working on previously. The first one below is what I just finished today but I am still stuck on the date one.
# easterDate2.py
# A program that calculates the date of Easter from 1900-2099.
# Brandon Brummert, October 21, 2008
def main():
print "Calculates the Date of Easter"
year = input("What year would like to know the date for easter? ")
if year < 1900:
print "This program only works for the years 1900 to 2099"
if year > 2099:
print "This program only works for the years 1900 to 2099"
if year >=1900:
a = year % 19
b = year % 4
c = year % 7
d = (19*a + 24) % 30
e = (2*b + 4*c + 6*d + 5) % 7
k = 22 + d + e
if year == 1954 or year == 1981 or year == 2049 or year == 2076:
k = (22 + d + e) - 31 - 7
if k <= 31:
print "Easter is March", k
if k > 31:
k = (22 + d + e) - 31
print "Easter is April", k
main()
here is the one that I am still stuck on. not much has changed since last time.
# dateCheck.py
# A program that accepts a date in the form month/day/year and outputs whether date is valid.
# Brandon Brummert, October 20, 2008
import string
def isLeapYear(leap):
if 0 == year % 400:
return True
elif 0 == year % 100:
return False
elif 0 == year % 4:
return True
else:
return False
def daysInMonth (date):
if 1 or 3 or 5 or 7 or 8 or 10 or 12:
return 31
elif 4 or 6 or 9 or 11:
return 30
elif 2:
return leap
def main():
currentdate= input ("What is the date (mm/dd/yyyy)?:")
month, date, year= string.split(currentdate)
print month/date/year
main()
________________________________________
From: bob gailer [[EMAIL PROTECTED]]
Sent: Tuesday, October 21, 2008 10:25 AM
To: Brummert_Brandon; tutorpythonmailinglist Python
Subject: Re: [Tutor] decision structures
Please reply to the tutor list, not just to me. We all learn and many of
us can help.
Brummert_Brandon wrote:
This is what I have so far. I am still confused by the string.split setup. Thank you.
# dateCheck.py
# A program that accepts a date in the form month/day/year and outputs whether date is valid.
# Brandon Brummert, October 20, 2008
import string
def isLeapYear(leap):
if 0 == year % 400:
return True
elif 0 == year % 100:
return False
elif 0 == year % 4:
return True
else:
return False
def daysInMonth (date):
if 1 or 3 or 5 or 7 or 8 or 10 or 12:
return 31
elif 4 or 6 or 9 or 11:
return 30
elif 2:
return leap
def main():
currentdate= input ("What is the date (mm/dd/yyyy)?:")
month, date, year= string.split(currentdate)
print month/date/year
main()
Thank you. That is half of the input I'm seeking. The other half is:
what happens when you run the program?
I'd expect you see a prompt:
What is the date (mm/dd/yyyy)?:
What do you enter at this prompt?
What happens next? You should see an exception (error). What is it? Why
do you think it means and why did it happen?
Read the documentation for input().
As an aside - your program shows very little understanding of Python.
Have you written other programs that ran the way you expected, or is
this your first try?
Since it is homework we don't write the program for you. I'm trying to
nudge you in the right direction, and would appreciate all you can give it.
Did you read the documentation for split?
month/date/year
is an _expression_. What does the / mean in an _expression_?
At the Python interpreter prompt >>> enter
if 1 or 3 or 5 or 7 or 8 or 10 or 12:
print True
What happens? Why? Then try
if 1:
print True
You are trying to compare date to numbers yet date does not appear in
the if statement!
I have mentioned lists twice yet you have not said anything about them.
Do you know what a list is and how it can be used?
--
Bob Gailer
Chapel Hill NC
919-636-4239
When we take the time to be aware of our feelings and
needs we have more satisfying interatctions with others.
Nonviolent Communication provides tools for this awareness.
As a coach and trainer I can assist you in learning this process.
What is YOUR biggest relationship challenge?