Question: def season(num_of_month): Problem 1 The function season() is defined. Then the number input to the function needs to be tested in order to figure

def season(num_of_month):

"""

Problem 1

The function season() is defined.

Then the number input to the function needs to be tested

in order to figure out which season the month number falls under.

HW4_Exception handling: month is not in 1 to 12 range or month is not a number

"""

if month>=1 and month<=3:

return 'Winter'

elif month>=4 and month<=6:

return 'Spring'

elif month>=7 and month<=9:

return 'Summer'

else:

return 'Fall'

def quote(filename, line_num):

"""

Problem 3

Define the two variable you require for the function quote().

Open "wilde_quotes.txt" and get the number of lines.

Create a varaible for the the line that is going to be returned

and since it's a string, subtract 1 from the input integer.

Return the answer

HW4_Exception handling: filename is not available

"""

infile = open(filename)

linelist = infile.readlines()

return_line = linelist[line_num - 1]

infile.close()

return return_line

def scout_name(first_name, last_name):

"""

Problem 4

returns a string of the form 'L First'

HW4_Exception handling: first_name and last name is not string

>>> scoutName('Albert', 'Einstein')

'E. Albert'

"""

return last_name[0]+ '. ' + first_name

Find all errors and correct them

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!