write a python code on pycharm
Leap Year: A year is called a leap year if it contains an additional day which makes the number of the days in that year is 366. This additional day is added in February which makes it 29 days long. A leap year occurred once every 4 years. Design a program that asks the user if he/she wants to check a year, if he/she enters Y or y let him her enter a year number. The program should contain Function (leap_check) to check if leap year or not. You should follow the following steps to determine whether a year is a leap year or not. 1. If a year is evenly divisible by 4 means having no remainder then go to next step. If it is not divisible by 4. It is not a leap year. For example: 1997 is not a leap year. 2. If a year is divisible by 4, but not by 100. For example: 2012, it is a leap year. If a year is divisible by both 4 and 100, go to next step. 3. If a year is divisible by 100, but not by 400. For example: 1900, then it is not a leap year. If a year is divisible by both, then it is a leap year. So 2000 is a leap year. The program should save the result in the file (leapyear.txt)
Sample input/output: IN Leap Year Checker This program will check if a year you input is a leap year Would you like to check a year?(Enter y for yes and any key for No): Y Enter a year: 1997 1997 is not a leap year Would you like to check another year?(Enter y for yes and any key for No): Y Enter a year: 2012 2012 is a leap year Would you like to check another year?(Enter y for yes and any key for No): Y Enter a year: 1900 1900 is not a leap year Would you like to check another year?(Enter y for yes and any key for No): Y Enter a year: 2000 2000 is a leap year Would you like to check another year? (Enter y for yes and any key for No): N leapyear.txt file: Year Type 1997 not a leap year 2012 a leap year 1900 not a leap year 2000 a leap year
write a python code on pycharm
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am