Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Change the year in 2nd line to get the answer for the year you want. Ex: year=2010

# Python program to check if year is a leap year or not
year = 2004
# To get year (integer input) from the user
# year = int(input("Enter a year: "))
# divided by 100 means century year (ending with 00)
# century year divided by 400 is leap year
if (year % 400 == 0) and (year % 100 == 0):
    print("{0} is a leap year".format(year))
# not divided by 100 means not a century year
# year divided by 4 is a leap year
elif (year % 4 ==0) and (year % 100 != 0):
    print("{0} is a leap year".format(year))
# if not divided by both 400 (century year) and 4 (not century year)
# year is not leap year
else:
    print("{0} is not a leap year".format(year))
Comment

PREVIOUS NEXT
Code Example
Python :: python strftime iso 8601 
Python :: how to install cuda in anaconda 
Python :: how to open a website with selenium python 
Python :: django text area limit characters 
Python :: list to set keep order python 
Python :: face detection 
Python :: pil image from numpy 
Python :: pandas count nan in each row 
Python :: python requests set header cookie 
Python :: list of files in python 
Python :: pandas replace nulls with zeros 
Python :: standard module 
Python :: get list of users django 
Python :: how to check if a message includes a word discord.py 
Python :: how to take two integers as input in python 
Python :: python input map 
Python :: python pause 
Python :: vsc python close all functions 
Python :: plt axis tick color 
Python :: plt close all 
Python :: python project ideas 
Python :: how to move the pointer on screen using python 
Python :: append row to array python 
Python :: average within group by pandas 
Python :: code for making an exe file for python 
Python :: get all combinations from two lists python 
Python :: how to find shortest string in a list python 
Python :: create directory in python 
Python :: how to get user ip in python 
Python :: display result in same page using flask api 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =