473,399 Members | 3,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

HELP plz [to determine leap year]

1
Hi please could someone help. i have created this programming so you can work out if there is a LEAP YEAR. But i need it to handle centuries. heres the code

Expand|Select|Wrap|Line Numbers
  1. def isLeapYear (year):
  2.     result = year % 4
  3.     if result > 0:
  4.         print "It is NOT a leap year"
  5.     else:
  6.         print "It IS a leap year"
  7.  
  8.         Result = (year * 100) % 4
  9.         if result >0:
  10.             print "It is NOT a leap year"
  11.  
  12. isLeapYear(400)
  13. isLeapYear(800)
  14. isLeapYear(1600)
  15. isLeapYear(1601)
  16. isLeapYear(2004)
  17. isLeapYear(2012)
  18. isLeapYear(3010)
  19. isLeapYear(3330)
  20.  
  21.  
Please can someone help me out sort it out. THANX
Apr 4 '07 #1
3 3630
ilikepython
844 Expert 512MB
We can help but your code would be easier to understand if you use code tags around your code. See the posting guidelines for help with that.
Repost your code and someone will help you
Apr 4 '07 #2
bartonc
6,596 Expert 4TB
Hi please could someone help. i have created this programming so you can work out if there is a LEAP YEAR. But i need it to handle centuries. heres the code

Expand|Select|Wrap|Line Numbers
  1. def isLeapYear (year):
  2.     result = year % 4
  3.     if result > 0:
  4.         print "It is NOT a leap year"
  5.     else:
  6.         print "It IS a leap year"
  7.  
  8.         Result = (year * 100) % 4
  9.         if result >0:
  10.             print "It is NOT a leap year"
  11.  
  12. isLeapYear(400)
  13. isLeapYear(800)
  14. isLeapYear(1600)
  15. isLeapYear(1601)
  16. isLeapYear(2004)
  17. isLeapYear(2012)
  18. isLeapYear(3010)
  19. isLeapYear(3330)
  20.  
  21.  
Please can someone help me out sort it out. THANX
Capital 'R' is messing you up.
Expand|Select|Wrap|Line Numbers
  1.         Result = (year * 100) % 4
  2.  
Apr 4 '07 #3
Capital 'R' is messing you up.
Expand|Select|Wrap|Line Numbers
  1.         Result = (year * 100) % 4
  2.  
Expand|Select|Wrap|Line Numbers
  1. Last2Digits = year % 100
  2. if (Last2Digits == 0):
  3.     flag = year % 400
  4. else:
  5.     flag = year % 4
  6.  
  7. if (flag == 0):
  8.     print " is a Leap year"
  9. else:
  10.     print " is not a Leap year"
Apr 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Se'noj | last post by:
Hi all, In a program I am writing, I need to convert a date stored as an integer number of days into a standard gregorian format, with day zero being 1/1/1800. Can anyone help me with this? ...
14
by: Protoman | last post by:
Hi!!! I need some help on a project I'm that calculates leap years; I'm getting errors that I have no idea what they mean; here's the code: #include <iostream> #include <cstdlib> using...
13
by: vgame64 | last post by:
Hi, I have been struggling with writing a program for a few hours. The requirements are that: """You will be writing a program which will determine whether a date is valid in terms of days in that...
22
by: deepak.rathore | last post by:
can someone give the regular expr. to validate leap yr like 02/29/2000,02/29/00 Thanks
8
by: rn216_ccc | last post by:
Hi there all, I found a web site,. http://www.onlineconversion.com/leapyear.htm, where it can give a list of leap years by within the given range by the user, or the user may enter a year and the...
37
by: mazwolfe | last post by:
I'm new here, so excuse me if my style is incorrect. Can anyone come up with a better method for this calculation? Code: int is_leap(int year) { switch (year % 19) { case 0: case 3: case 6:...
5
by: jimix | last post by:
here's what i have. using microsoft studio #define _CRT_SECURE_NO_DEPRECATE #include <stdio.h> int main( void ) { int year, b, c, e; b = 4; c = 100;
7
by: gubbachchi | last post by:
Hi all, In my application I need to display the data fetched from mysql database after the user selects date from javascript calender. I have written the code in which after the user selects the...
4
by: hallsers | last post by:
Here is the problem i am having: - When a user logs in, on page load it will take the dob of all users in a stored friends list and compare them against the following conditions - To display any...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.