Hello! I am using python for this calendar program but it doesn't work pls. help me.

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

Hello! I am using python for this calendar program but it doesn't work pls. help me. Thank you.

Here is the code

# Calendar Year Program (Final Version)

#initialization

terminate = False

days_in_month = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)

month_names = ('January','February','March','April','May','June','July','August','September','October','November','December')

calendar_year = []

month_separator = format(' ', '8')

blank_week = format(' ', '21')

blank_col = format(' ', '3')

# prompt for years until quit

while not terminate:

    # program greeting

    print('This program will display a calendar year for a given year')

    # get year

    year = int(input('Enter year (yyyy) (-1 to quit): '))

    while (year < 1800 or year > 2099) and year != -1:

        year = int(input('INVALID - Enter year (1800-2099): '))   

    if year == -1:

        terminate = True

    else: 

        # determine if leap year

        if (year % 4 == 0) and (not(year % 100 == 0) or (year % 400 == 0)):

            leap_year = True

        else:

            leap_year = False   

        # 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

        # leap year check

        if not leap_year:

            value = value + 1

        # determine the first day of the month for January 1

        first_day_of_current_month = (value + 1) % 7 

        # construct calendar for all 12 months

        for month_num in range(12):

            month_name = month_names[month_num]  

            #init for new month

            current_day = 1

            if first_day_of_current_month == 0:

                starting_col = 7

            else:

                starting_col = first_day_of_current_month

                current_col = 1

                calendar_week = ''

                calendar_month = []

                

                # add any needed leading space for the first week of the month

                while current_col < starting_col:

                    calendar_week = calendar_week + blank_col

                    current_col = current_col + 1

                    

                # store month as separate weeks

                if (month_name == 'February') and leap_year:

                    num_days_this_month = 29

                else:

                    num_days_this_month = days_in_month[month_num]

                

                while current_day <= num_days_this_month:

                    

                    #store day of month in field of length 3

                    calendar_week = calendar_week + format(str(current_day), '>3')

                        

                    # check if at last column of displayed week

                    if current_col == 7:

                        calendar_month == calendar_month + [calendar_week]

                        calendar_week = ''

                        current_col = 1

                    else:

                        current_col = current_col + 1

                        

                    #increment current day

                    current_day = current_day + 1

                    

                #fill out final row of the month with needed blanks

                calendar_week = calendar_week + blank_week[0: (7-current_col+1) * 3]

                calendar_month = calendar_month + [calendar_week]

                

                #reset values for next month

                first_day_of_current_month = current_col

                calendar_year = calendar_year + [calendar_month]

                calendar_month = []

                

            # print calendar year

            print('\n', year, '\n')

            

            # each row starts with January, April, July or October 

            for month_num in [0,3,6,9]:

                

                # displays 3 months in each row

                for i in range(month_num, month_num + 3):

                    print('' + format(month_names[i], '19'),

                          month_separator, end='')

                    

                # display each week on separate lines

                week = 0

                lines_to_print = True

                while lines_to_print:

                    

                    #init

                    lines_to_print = False

                    

                    # another week to display for first month in row?

                    for k in range(month_num, month_num + 3):

                        if week < len(calendar_year[k]):

                            print(calendar_year[k][week], end='')

                            lines_to_print = True

                        else:

                            print(blank_week, end='')

                            

                        print(month_separator, end='')

                        

                    # move to the next screen line

                    print()

                    

                    # increment week

                    week = week + 1

M7. Calendar Year Program: Flexible Calendar Format
The program as is always displays three months per row. Modify the Calendar Year program so that the
user can select how many months are displayed per row. Allow the user to select either two, three, or four
months per row.
Transcribed Image Text:M7. Calendar Year Program: Flexible Calendar Format The program as is always displays three months per row. Modify the Calendar Year program so that the user can select how many months are displayed per row. Allow the user to select either two, three, or four months per row.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
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