Programming Examples

Python program to take two inputs for day month and then calculate which day of the year


Write a program to take two inputs for day, month and then calculate which day of the year, the given date is. For simplicity, take 30 days for all months. For example, if you give input as: Day3, Month2 then it should print "Day of the year : 33".

Solution

d = int(input("Enter day: "))
m = int(input("Enter month: "))

n = (m - 1) * 30 + d

print("Day of the year:", n)
Output

Enter day: 3

Enter month: 2

Day of the year: 33

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz