0

Hi,
I am trying to write a code that will calculate easter date within a year range.The problem i have is that no matter what date i put either within or outside the range i get the same output.Here is the code

    #A programme to calculate date of easter

    def main():
        year=input('Enter a year between 1982-2048 ')
        if year==range(1982,2049):
            a=year%19
            b=year%4
            c=year%7
            d=((19*a)+24)%30
            e=((2*b)+(4*c)+(6*d)+5)%7
            f=22+d+e
            if f<=31:
                        print " Easter in on March",f
                    else:
                        print "Easter is on April",f-31
        else:
                print 'Year is not within range'

    main()

Thanks for the help in advance.

3
Contributors
2
Replies
4
Views
4 Years
Discussion Span
Last Post by ZZucker
0

User input can not be the whole range use in. Your indention is off for the if statement in lines 12-17.

Edited by pyTony

0

Try something like this:

# A program to calculate date of Easter

def calc_easter(year):

    if year in range(1982, 2049):
        a = year % 19
        b = year % 4
        c = year % 7
        d = ((19*a) + 24)%30
        e = ((2*b) + (4*c) + (6*d) + 5)%7
        f = 22 + d + e
        if f <= 31:
            print(" Easter in on March %d" % f)
        else:
            print("Easter is on April %d" % (f - 31))
    else:
        print("Year is not within range")

year = int(input('Enter a year between 1982-2048 '))
calc_easter(year)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.