lease help me do M9. I am using python. Currently, this is my code. How can I use the month name as my entry?

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Please help me do M9. I am using python. Currently, this is my code. How can I use the month name as my entry?

#Python

# Calendar Month Program

# init
terminate = False

# program greeting
print('This program will display a calendar month betwee 1800 and 2099')

while not terminate:
    # get the month and year
    month = int(input('Enter month 1-12 (-1 to quit): '))
   
    if month == -1:
        terminate = True
    else:
        while month < 1 or month > 12:
            month = int(input('INVALID - Enter month (1-12): '))
           
        year = int(input('Enter year (yyyy): '))
       
        while year < 1800 or year > 2099:
            year = int(input('INVALID -Enter year (1800-2099): '))
       
        leapYear = ""
        # determine if leap year
        if (year % 4 == 0) and (not(year % 100 == 0)) or (year % 400 == 0):
            leap_year = True  
            leapYear = "(leap year)"  
        else:
            leap_year = False
           
        # determine the number of days in a month
        if month in (1,3,5,7,8,10,12):
            num_days_in_month = 31
        elif month in (4,6,9,11):
            num_days_in_month = 30
        elif leap_year: #February
            num_days_in_month = 29
        else:
            num_days_in_month = 28
           
        # determine the day of the week
        century_digits = year // 100
        year_digits = year % 100
       
        value = year_digits + (year_digits // 4)
       
        if century_digits == 18:
            value = value + 2
        elif century_digits == 20:
            value = value + 6
           
        if month == 1 and not leap_year:
            value = value + 1
        elif month == 2:
            if leap_year:
                value = value + 3
            else:
                value = value + 4
        elif month == 3 or month == 11:
            value = value + 4
        elif month == 5:
            value = value + 2
        elif month == 6:
            value = value + 5
        elif month == 8:
            value = value + 3
        elif month == 9 or month == 12:
            value = value + 6
        elif month == 10:
            value = value + 1
           
        day_of_week = (value + 1) % 7 #1-Sun, 2-Mon,...,0-Sat
               
        # determine month name
        if month == 1:
            month_name = 'January'
        elif month == 2:
            month_name = 'February'
        elif month == 3:
            month_name = 'March'
        elif month == 4:
            month_name = 'April'
        elif month == 5:
            month_name = 'May'
        elif month == 6:
            month_name = 'June'
        elif month == 7:
            month_name = 'July'
        elif month == 8:
            month_name = 'August'
        elif month == 9:
            month_name = 'September'
        elif month == 10:
            month_name = 'October'
        elif month == 11:
            month_name = 'November'
        else:
            month_name ='December'
           
        # display month and year heading
        print('\n', ' ' + month_name, year, leapYear)
        print(' ','Su ', 'Mo ', 'Tu ', 'We ', 'Th ', 'Fr ', 'Sa ')
       
        # display rows of dates
        if day_of_week == 0:
            starting_col = 7
        else:
            starting_col = day_of_week
           
        current_col = 1
        column_width = 4
        blank_char = ' '
        blank_column = format(blank_char, str(column_width))
       
        while current_col < starting_col:
            print(blank_column, end='')
            current_col = current_col + 1
           
        current_day = 1
       
        while current_day <= num_days_in_month:
            if current_day < 10:
                print(format(blank_char, '3') + str(current_day), end='')
            else:
                print(format(blank_char, '2') + str(current_day), end='')
               
            if current_col < 7:
                current_col = current_col + 1
            else:
                current_col = 1
                print ()
               
            current_day = current_day + 1
           
        print ('\n')

 

M9. Calendar Month Program: User Entry of Month Name
Modify the final version of the Calendar Month program to allow the user to enter a month's name
(e.g., 'January') rather than a number (e.g., 1). Make all appropriate changes in the program as a
result of this change.
Transcribed Image Text:M9. Calendar Month Program: User Entry of Month Name Modify the final version of the Calendar Month program to allow the user to enter a month's name (e.g., 'January') rather than a number (e.g., 1). Make all appropriate changes in the program as a result of this change.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY