need some help on the coding can some plz help
the question is:
A year is a leap year if it is divisible by 4, unless the year is a Century, in which case it is
only a leap year if it is divisible by 400. Write a function which takes a year as an argument
and prints a message to the screen saying whether or not that year is a leap year.

this the ouline that i have got:

1 def isLeapYear ( year ):
2 ...
3
4 # Testing ...
5 isLeapYear (400)
6 isLeapYear (800)
7 isLeapYear (1600)
8 isLeapYear (1601)
9 isLeapYear (2004)
10 ...

ive come up with some coding of my own but it doesnt work:

((Year % 4 == 0) and (not (Year % 100 == 0))) or (Year % 400 == 0)
(Year % 4 == 0) and not (Year % 100 == 0) or (Year % 400 == 0)

Try this

# python >= 2.5
def isLeapYear(year):
    return False if year % 4 else True if year % 100 else not year % 400

:)

first of all thanks for helping now i have try the code but it comes back with

indentationerror: expected an indented block

ok i have added the 4 spaces and no errors displayed but three dots come

...

so shall i add the rest of the code provide or was it going to print it all automatically

ok i have added the 4 spaces and no errors displayed but three dots come

...

so shall i add the rest of the code provide or was it going to print it all automatically

Three dots? Are you using the Python shell?

how do i make the code print out this info automaically

4 # Testing ...
5 isLeapYear (400)
6 isLeapYear (800)
7 isLeapYear (1600)
8 isLeapYear (1601)
9 isLeapYear (2004)
10 ...

Something like this:

def isLeapYear(year):
    """
    return True if year is a leapyear
    """
    return (not year%4 and year%100 or not year%400) and True

# Testing ...
print( isLeapYear(400) )
print( isLeapYear(800) )
print( isLeapYear(1600) )
print( isLeapYear(1601) )
print( isLeapYear(2004) )

on line 2 ... when i press enter an error comes up so how can i enter the rest of the code

hey thanks sneekula for the help and thanks to everyone who help it worked thanks alot

i guess this should do the trick...

int leap ( int int x)
{
                       if  (!(x%100) && ( x %400 || x %4))
                                     return 1;
 }

well it will return 1 if the year is leap year or not

i guess this should do the trick...

int leap ( int int x)
{
                       if  (!(x%100) && ( x %400 || x %4))
                                     return 1;
 }

well it will return 1 if the year is leap year or not

Ouch, you are in a different world! That looks like old, ugly, and badly written C code.

well at first i completyl apologise cuz when i saw the thread , i actually didnt navigate thru the forum section , so just mistook as c form

second of all

Ouch, you are in a different world! That looks like old, ugly, and badly written C code.

well even though its a c code , i dont see any kind of ugliness in the code.i am glad if u could be specific in pointing out the so called
"old, ugly, and badly" in the code.

how could i find leap year , using python programing also by using constructors................

I think this old thread contains the answer of the leap year problem. Did you test the solution ? Otherwise you can start a new thread and post your code.

The c code line
int leap ( int int x)
will give error: two or more data types in declaration of `x'
this is bad coding!

This question has already been answered. Start a new discussion instead.