Write a Python program to give the month name when no. is entered by user

Python program to print month name for user entered number

Problem Statement: Write a Python program to give the month name when no. is entered by the user 

Programming Language: Python 3

Software: Anaconda Jupyter Notebook




Python Program:

# Enter number betwen 1 to 12 and convert it to Integer datatype
month_no = int(input("Enter the number between 1 to 12: "))

if month_no == 1:
print("Month Name is: January")
elif month_no == 2:
print("Month Name is: February")
elif month_no == 3:
print("Month Name is: March")
elif month_no == 4:
print("Month Name is: April")
elif month_no == 5:
print("Month Name is: May")
elif month_no == 6:
print("Month Name is: June")
elif month_no == 7:
print("Month Name is: July")
elif month_no == 8:
print("Month Name is: August")
elif month_no == 9:
print("Month Name is: September")
elif month_no == 10:
print("Month Name is: October")
elif month_no == 11:
print("Month Name is: November")
elif month_no == 12:
print("Month Name is: December")
else:
print("Entered number is Invalid. \nEnter a valid number between 1 to 12")




Output:

Enter the number between 1 to 12: 9
Month Name is: September

Enter the number between 1 to 12: 1
Month Name is: January

Enter the number between 1 to 12: 7
Month Name is: July

Enter the number between 1 to 12: 13
Entered number is Invalid.
Enter a valid number between 1 to 12



--------------------------------------------------------------------------------
Click here to see solutions for all Machine Learning Coursera Assignments.
&
Click here to see more codes for Raspberry Pi 3 and similar Family.
&
Click here to see more codes for NodeMCU ESP8266 and similar Family.
&
Click here to see more codes for Arduino Mega (ATMega 2560) and similar Family.
Feel free to ask doubts in the comment section. I will try my best to answer it.
If you find this helpful by any mean like, comment and share the post.
This is the simplest way to encourage me to keep doing such work.

Thanks & Regards,
-Akshay P Daga
Post a Comment (0)
Previous Post Next Post