caz27
14.09.2019 •
Computers and Technology
Time and weather write a program to take as input and 4-digit number from the user. the first two digits represent the day of the month and the last two digits represent the month of the year. the program should then display the following: "it's winter" if the month entered is 12, 1 or2 . "it's spring" if the month entered is 3, 4, or 5 "it's summer", if the month entered is 6,7, or 8 "it's fall", if the month entered is 9, 10, or 11 the program should also display the current week number of the month
Solved
Show answers
More tips
- F Food and Cooking When is Easter in 2011?...
- L Leisure and Entertainment Scrapbooking: What is it and Why is it Becoming More Popular?...
- H Horoscopes, Magic, Divination How to Cast a Love Spell on a Guy? Guide for Guys...
- F Family and Home How to Sew Curtain Tapes: Best Tips from Professionals...
- S Style and Beauty How are artificial nails removed?...
- S Style and Beauty How to Make Your Lips Fuller? Ideas and Tips for Beautiful Lips...
- F Food and Cooking The Disease That Haunted Abraham Lincoln...
- C Computers and Internet How to Get Rid of Windows Genuine Check?...
- H Health and Medicine How to perform artificial respiration?...
- S Style and Beauty Tricks and Tips: How to Get Rid of Freckles...
Answers on questions: Computers and Technology
- E English According to the author, which of the following statements about ghosts in Europe is accurate?...
- M Mathematics The table and corresponding image show the proof of the relationship between the slopes of two parallel lines. What is the missing statement in step 2? I have the...
- B Biology How did geologists decide where one division of the geologic time scale ends and the next begins? the law of superpostion events in the history of life on earth,...
Ответ:
#here is program in python
#read 4 digit number
date=int(input("enter the date:"))
#first 2 digit is day
day=int(date/100)
#last 2 digit is month
month=date%100
#find the week of the month
if day<=7:
week=1
elif day>=8 and day<=14:
week=2
elif day>=15 and day<=21:
week=3
elif day>=22 and day<=28:
week=4
elif day>=29:
week=5
#check for Winter
if month in [12,1,2]:
print("week {} of Winter.".format(week))
# check for Spring
elif month in [3,4,5]:
print("week {} of Spring.".format(week))
#check for Summer
elif month in [6,7,8]:
print("week {} of Summer.".format(week))
#check for Fall
elif month in [9,10,11]:
print("week {} of Fall.".format(week))
Explanation:
Read a 4 digit number from user.first 2 digits represents the day and last 2 month.Then find the week of the month.If the month is in [12,1,2] then it will print "Winter" and week of that month.If month is in [3,4,5] then print "Summer" with week.If the month is in [6,7,8] then "Summer" and if the month is in [9,10,11] then "Fall".
Output:
enter the date:1212
week 2 of Winter.
Ответ: