CBSE Class 11 Computer Science Question 157 of 173

Data Handling — Question 9

Back to all questions
9
Question

Question 9

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
Answer