Computer Science, asked by akshayakz10117, 6 months ago

write a python program to input month number of days in that month​

Answers

Answered by rehinidebbarma33
3

Answer:

Input the month and year from the user. If the year is a leap year and (month == 2), display "Number of days is 29". Else if (month == 2), display "Number of days is 28". Else if((month == 1) ||(month == 3 || (month == 5) (month == 7) || (month == 8) || (month == 10) (month == 12)), display "Number of days is 31".

Answered by surajnegi0600
1

Answer:

Here is a Python program that inputs a month number and outputs the number of days in that month:

month = int(input("Enter a month number: "))

if month == 2:

 print("28 or 29 days")

elif month in (4, 6, 9, 11):

 print("30 days")

elif month in (1, 3, 5, 7, 8, 10, 12):

 print("31 days")

else:

 print("Invalid month")

Explanation:

This program uses the input() function to get the user's input as a string, then it converts the input to an integer using the int() function.

Then it uses an if-elif-else statement to check the input month number:

If the month is 2, it will print "28 or 29 days"

If the month is 4, 6, 9, or 11 it will print "30 days"

If the month is 1, 3, 5, 7, 8, 10, or 12 it will print "31 days"

If the input is not one of the above, it will print "Invalid month"

It is important to note that the program doesn't take into account the leap year, if you want to consider leap year you can add an additional condition for it.

More question and answers:

https://brainly.in/question/13890400

https://brainly.in/question/29468164

#SPJ3

Similar questions