Answered step by step
Verified Expert Solution
Question
1 Approved Answer
python 1. The Date class has three fields, year, month and day. The class is partially defined below. from functools import total_ordering @total_ordering class Date:
python
1. The Date class has three fields, year, month and day. The class is partially defined below. from functools import total_ordering @total_ordering class Date: def init__(self, year, month, day): self year = year self.month = month self day = day Complete the following methods. a) The _repr_(self) method returns a string of form 'Date(2020..10,_21)' when the self object represents the date (21 October, 2020). def __repr_(self): " (Remove @total ordering for now.) Input >>> Date(2020, 10, 21) in the Shell window to verify your code. b) The str_(self) method returns a string of form '21-OCT-2020' when the self object repre- sents the date (21 October, 2020). You can put the month names in a list and use the month value as the index to get the name. def str_(self): 2 c) The (Remove @total_ordering for now.) Input >>> print (Date(2020, 10, 21))) in the Shell window to verify your code. eq__(self, other) method returns True if the self object and the other object represent the same date, otherwise False. def __eq_(self, other): 1/3 d) The _lt_(self, other) method returns True if the self date is strictly earlier than the other date, otherwise False. def _lt_(self, other): (4 (Put bac! Ir otal_ordering.) = Date(20Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started