Articles

Python program to find number of days in February month

Python program to find number of days in February month


Program Statement: WAP in python to check the number of days in february and also calculate the number of days in that particular year using python programming language.

 

PROGRAM TO ABOVE QUESTION IS GIVEN BELOW:

Python program to find number of days in a month february is given below:

yr=int(input("enter the year:"))
if(yr%100==0):
    if(yr%400==0):
        print("feb has 29 days in the given year  "+str(yr))
        print("no of days in "+str(yr)+ " is 366")
    else:
        print("feb has 28 days in the given year "+str(yr))
        print("no of days in "+str(yr)+ " is 365")
elif(yr%4==0):        
        print("feb has 29 days in the given year "+str(yr))
        print("no of days in "+str(yr)+ " is 366")
else:
        print("feb has 28 days in the given year "+str(yr))
        print("no of days in "+str(yr)+ " is 365")

🧐Explanation:

In the above program,

  • we have first  checked whether  the year is leap year or not.
  • If the year is a leap  year,then february has 29 days or
  • if it is not leap year then february has 28 days .
  • So we have used this concept in the above program. 

🛠Output to the above program is shown below in python:

 

🛠1st Run case:

 

enter the year:2015
feb has 28 days in the given year 2015
no of days in 2015 is 365

💼2nd Run case:

 

enter the year:1700
feb has 28 days in the given year 1700
no of days in 1700 is 365

📡3rd Run case:

 

enter the year:2016
feb has 29 days in the given year 2016
no of days in 2016 is 366

We have come to end of our article. Our program executes successfully. Thank you for reading this article.


Basic Python Programs

Would you like to see your article here on tutorialsinhand. Join Write4Us program by tutorialsinhand.com

About the Author
Ayush Bajpai
I am a data science enthusiast. I love to learn new technology 🛠🛠.you can reach me at this url www.linkedin.com/in/ayushbajpai47
Page Views :    Published Date : Jun 01,2021  
Please Share this page

Related Articles

Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!