0% found this document useful (0 votes)
19 views

Python Programme To Check - #If A Year Is Leap Year or Not

The document describes a Python program to check if a given year is a leap year or not. It takes the year as input, then uses modulo operators and conditional statements to check if the year is divisible by 4, 100 or 400 to determine if it is a leap year or not.

Uploaded by

wellall675
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Python Programme To Check - #If A Year Is Leap Year or Not

The document describes a Python program to check if a given year is a leap year or not. It takes the year as input, then uses modulo operators and conditional statements to check if the year is divisible by 4, 100 or 400 to determine if it is a leap year or not.

Uploaded by

wellall675
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

1.

#Python Programme To Check


2. #IF a year is leap year or not
3. #Any year is leap year only if its divisible by 4 or 400 for years ending with 00
4. #Thats why 1900 is not a leap year
5. Year=int(input("Enter a year: ")) #Input line
6. #Check if its divisible by 400
7. if(Year%400==0):
8. print(Year,"is a leap year")
9. #Check if its divisible by 100
10. elif(Year%100==0):
11. print(Year,"is not a leap year")
12. #Check if its divisible by 4
13. elif(Year%4==0):
14. print(Year,"is a leap year")
15. else:
16. print(Year,"is not a leap year")
17.
18. #x%y means remainder if we divide x by y
19. #For example if we write 7%5 that means it is 2 as 7=1×5+2

Output Section :
Enter a year: 2020

2020 is a leap year

Enter a year: 2023

2023 is not a leap year

Enter a year: 2000

2000 is a leap year

Enter a year: 1900

1900 is not a leap year

You might also like