Cognizant Coding Questions and Answers 2022
Problem Statement –
Rhea Pandey’s teacher has
asked her to prepare well for the lesson on seasons. When her teacher tells a
month, she needs to say the season corresponding to that month. Write a program
to solve the above task.
Spring – March to May,
Summer – June to August,
Autumn – September to November
and,
Winter – December to February.
Month should be in the range 1
to 12. If not the output should be “Invalid month”.
Sample Input 1:
Enter the month:11
Sample Output 1:
Season:Autumn
Sample Input 2:
Enter the month:13
Sample Output 2:
Invalid month
Program :
mon=int(input("Enter month : "))
if(mon==12 or mon==1 or mon==2):
print("Season : Winter")
elif(mon==3 or mon==4 or mon==5):
print("Season : Spring")
elif(mon==6 or mon==7 or mon==8):
print("Season : Summer")
elif(mon==9 or mon==10 or mon==11):
print("Season : Autumn")
else:
print("Invalid month")
for execution and output so check the video :
Comments
Post a Comment