monthrange() function in python by R4R Team

- monthrange() is a python function which return the first week day and the number of days in the given month.

Syntax-

calendar.monthrange(year,month)


program-

#import calendar module
import calendar

print("Enter year")
y=int(input())
print("Enter month")
m=int(input())
t=calendar.monthrange(y,m)
print(t)

print("Number of days is",t[1])


output-

Enter year
2019
Enter month
2
(4, 28)
Number of days is 28


-In this program, we take a input of the year and the month then by using monthrange() function we get first week day and the number of days in given month of given year.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!