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

Respuesta :

Answer:

#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.