Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON CLASS Will like if you answer please. [5 pts] Now implement a less_by_id() function which will compare two Person objects by their ID, and

PYTHON CLASS

Will like if you answer please.

image text in transcribed

[5 pts] Now implement a less_by_id() function which will compare two Person objects by their ID, and a less_by_name) function which will compare two Person objects by their names. () # Put your comparison functions here. Test code below. Do not change. 0 1 = [Person(3, "Joe"), Person(2, "Alice"), Person (4, "Mike"), Person(1, "Jane") } print(1) for ein 1: print(e) print (sort(l, less_by_id)) print (sortil, loss_by_namo) ) [25 pts) For this next problem, write a simulation of the Monty Hall problem. Implement the simulation as a function named monty) that takes two parameters. The first parameter is the number of trials, and the second parameter is whether or not to switch doors after Monty reveals the door containing the goat. A few functions that you may need include: random. rendint() random. sample) random.shuffle() I also suggest that you use the Python set sequence class. [5 pts] Now implement a less_by_id() function which will compare two Person objects by their ID, and a less_by_name) function which will compare two Person objects by their names. () # Put your comparison functions here. Test code below. Do not change. 0 1 = [Person(3, "Joe"), Person(2, "Alice"), Person (4, "Mike"), Person(1, "Jane") } print(1) for ein 1: print(e) print (sort(l, less_by_id)) print (sortil, loss_by_namo) ) [25 pts) For this next problem, write a simulation of the Monty Hall problem. Implement the simulation as a function named monty) that takes two parameters. The first parameter is the number of trials, and the second parameter is whether or not to switch doors after Monty reveals the door containing the goat. A few functions that you may need include: random. rendint() random. sample) random.shuffle() I also suggest that you use the Python set sequence class

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

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions