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.
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.
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