Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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 here

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

Step: 3

blur-text-image

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

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions