Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PYTHON CLASS Will like if you answer please. [5 pts) In the cell below, put your comparator functions. You will need to implement two different
PYTHON CLASS
Will like if you answer please.
[5 pts) In the cell below, put your comparator functions. You will need to implement two different comparator functions. The less_than) comparator will sort in ascending order. The greater than( ) comparator will result in a descending order sort. [] # Put your less_than) and greater than() function here. [3 pts] The cell below will test your sort function. Do not change the code, except for lambda question. [] print (sort{[5, 4, 3, 2, 1, 1, 2, 6, 7, 8], less_than)) print(sort{[5, 4, 3, 2, 1, 1, 2, 6, 7, 8], greater_than) # For 3 pts, use a lambda to make this sort also sort in descending order, but # using the less_than() comparator. Hintt Change the sign of the return value # of the less than( ) comparator. print(sort{[5, 4, 3, 2, 1, 1, 2, 6, 7, 8], lambda_goes_here)) (14 pts] Next, you will see how your sort function can be used to sort other types of objects, given appropriate comparator functions. In the cell below, create a Person class. The class should have two, per-instance data attributes, id and name, representing the ID and name of a person, respectively. The class should include a instantiation method named __init_0, which accepts as arguments the ID and name. To make debugging easier, also include a _repr_() method that will return a string to be used for printing. # Put your class hereStep 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