1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
velikii [3]
3 years ago
13

Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month and an in

t to represent the day. Ex: If the input is April 11, the output is: spring In addition, check if the string and int are valid (an actual month and day). Ex: If the input is invalid, the output is: invalid The dates for each season are: spring: March 20 - June 20 summer: June 21 - September 21 autumn: September 22 - December 20 winter: December 21 - March 19

Computers and Technology
2 answers:
victus00 [196]3 years ago
4 0

Answer:

#SECTION 1

while True:

   month = input("Input the month (e.g. January, February etc.): ")

   try:

       

       if month in ('January', 'February', 'March','April', 'May', 'June','July', 'August', 'September', 'October', 'November', 'December',):

           day = int(input("Input the day: "))

           try:

               if day > 31:

                   raise

               elif day == 31 and month in ('September', 'April', 'June', 'November'):

                   raise

               elif day > 29 and month == 'February':

                   raise

               else:

                   break

                   

           except:

               print('Invalid!!!')

               print('Day not correct')

           

       else:

           raise

   except:

       print('Invalid!!!')

       print('Enter correct Month')

 

     

#SECTION 2

if month in ('January', 'February', 'March'):

season = 'winter'

elif month in ('April', 'May', 'June'):

season = 'spring'

elif month in ('July', 'August', 'September'):

season = 'summer'

else:

season = 'autumn'

if (month == 'March') and (day > 19):

season = 'spring'

elif (month == 'June') and (day > 20):

season = 'summer'

elif (month == 'September') and (day > 21):

season = 'autumn'

elif (month == 'December') and (day > 20):

season = 'winter'

print("Season is",season)

Explanation:

#SECTION 1

This section ensures that a correct input is inserted. The try and except blocks in combination with IF statements are used to archive the result. The while loop will continue to run until a valid input is inserted.

In the first try block, It checks to see if the month inputted is a month that exists by comparing it  with a list of months, if it does not exist it raises an error and executes the except block and prints invalid and states the error that occurred.

If the first  TRY block executes successful, the program moves to the next, it takes an input for the number and ensures that us a valid number for each month. If the number is invalid, it raises an error and executes the try block which prints invalid and states the problem.

If al inputs are valid the program breaks out of the loop and proceeds to the next section.

#SECTION 2

In this section the data provided is used to calculate the season, by making use of IF statements and finally the season is printed.

I have attached a sample for you to see how the code runs by inputting some inaccurate values and accurate ones.

Diano4ka-milaya [45]3 years ago
3 0

Answer:

month = input()

day = int(input())

 

if month in ('January', 'February', 'March'):

season = 'Winter'

elif month in ('April', 'May', 'June'):

season = 'Spring'

elif month in ('July', 'August', 'September'):

season = 'Summer'

elif month in ('November'):

season = 'Autumn'

else:

   season='Invalid'

   

if (month == 'March') and (day > 19):

season = 'Spring'

elif (month == 'June') and (day > 20):

season = 'Summer'

elif (month == 'September') and (day > 21):

season = 'Autumn'

 

elif (month == 'December') and (day > 20):

season = 'Winter'

 

if (month =='January', 'February', 'March','April', 'May', 'June','July', 'August', 'September', 'October', 'November', 'December') and ((0>day)or(day>30)):

   season='Invalid'

#make sure to add the last line because they will ask about the day "39"  which is invalid

print(season)

Explanation:

You might be interested in
Which layer defines an interface that applications can use to request network services, rather than referring directly to applic
Scrat [10]
Explain what is meant by a limited data set and how this HIPAA rule may affect medical assistants
4 0
3 years ago
X = 1 if (A = 1 OR B = 1) OR (A = 0 AND B = 1
Gnoma [55]

Answer:

For question a, it simplifies.  If you re-express it in boolean algebra, you get:

(a + b) + (!a + b)

= a + !a + b

= b

So you can simplify that circuit to just:

x = 1 if b = 1

(edit: or rather, x = b)

For question b, let's try it:

(!a!b)(!b + c)

= !a!b + !a!bc

= !a!b(1 + c)

= !a!b

So that one can be simplified to

a = 0 and b = 0

I have no good means of drawing them here, but hopefully the simplification helped!

4 0
3 years ago
A weak fuel to air mixture along with normal airflow through a turbine engine may result in?
Sladkaya [172]

Answer:

A weak fuel to air mixture along with normal airflow through a turbine engine may result in <u>a lean die out</u>.

Explanation:

Lean die out is a type of problem that may occur in the turbine. This may result in the weak fuel to air mixture. In case if the mixture of fuel and air is getting low due to some reasons like leakage of gas or low speed of engine may result in dangerous conditions such as fire or blast in the turbine. This is called lean die out. In the result of this problem, the turbine can be burn with the blast and may leads to causalities.

5 0
3 years ago
Write six causes of data lost
just olya [345]
<span>1. Deleting files accidentally
</span>

2. Viruses and damaging malware

3. Mechanical damages of hard drive

4. Power failures

5. Theft of computer

6. Spilling coffee, and other water damages

7. Fire accidents and explosions

<span>Hope this helps.</span>
3 0
3 years ago
On laptops with a smart card reader installed, where is the smart card reader usually located?
dem82 [27]
Plenty of space in the palm rest
4 0
2 years ago
Other questions:
  • _____ is a method of delivering software, in which a vendor hosts the applications, and customers access these applications over
    10·1 answer
  • Each organization that provides host services on the public Internet is responsible for providing and maintaining DNS authoritat
    7·1 answer
  • What will happen if Sam goes to the View menu, clicks Toolbars, and then clicks Picture?
    12·2 answers
  • Small robots that can move around on the surface of a planet are called space shuttles.
    12·2 answers
  • Hi<br>is it right?<br>"I think there is a small mistake in the quotation(second not first)"​
    5·1 answer
  • PLZ HELP What will be the output? class num: def init (self.a): self. number = a mul* __(self. b) return self. number + b. numbe
    7·1 answer
  • What is the difference between electrical and electronic devices?
    5·2 answers
  • Which of these is installed only on Apple smartphones and tablets?
    5·2 answers
  • You are purchasing a new printer. Which of the following is the most important requirement?
    5·1 answer
  • Firewalls are available as a special hardware device or as software. A firewall will block packets of information that are from
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!