Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Below is the class definition for a Date class. It represents data using integers for the month and day. For example, February 5 has month

Below is the class definition for a Date class. It represents data using integers for the month and day. For example, February 5 has month number 2 and day equal to 5.

class Date:

def __init__ (self, month, day, year):

self.month = month

self.day = day

def advance(self):

self.day += 1

monthLengths = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

if self.day > monthLengths[self.day]:

self.day = 1

self.month += 1

if self.month > 12:

self.month = 1

Note: this data class ignores leap year.

A. The advance method has a single error that does not relate to leap year. Find the error and change the code to remove the error.

B. Implement the str method for the class. It should give a string representation of the date using the month name and date.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

8. Managers are not trained to be innovation leaders.

Answered: 1 week ago