Python 3 Script to Check Whether a Year is a Leap Year or Not Full Project For Beginners

Python 3 Script to Check Whether a Year is a Leap Year or Not Full Project For Beginners

 

Welcome folks today in this post we will check whether a year is a leap year or not in python 3. All the full source code of the application is shown below.

 

 

Get Started

 

 

In order to get started you need to make an app.py file and copy paste the following code

See also  Python 3 csv-merger Library Example Script to Merge or Combine Multiple CSV Files into One Output Script Full Project For Beginners

 

app.py

 

 

year = int(input("Enter a year:- "))   # Here, you take the input from the user

if(((year % 4 == 0) and (year % 100 != 0)) or (year % 400 == 0)):   
    """
    if a year is a multiple of four and a multiple of 100 i.e. if it is a multiple of 400 it is not a leap year
    """
    print("{0} is a leap year!!".format(year))
    """
    printing the output
    """
else:
    print("{0} is not a leap year!!".format(year))

 

See also  Python 3 Script to Download PDF Files From URL Using BeautifulSoup4 and Requests Library Full Tutorial For Beginners

 

Now if you execute this python script app.py by typing the below command

 

python app.py

 

 

 

 

Now you can see that in the above figure I have entered 2012 in the command line as you can see this is a leap year

 

Leave a Reply