And Now You Know Your ABC
Briefly

And Now You Know Your ABC
"Here's the task. I want to create a class to represent a track and field event held in a competition. This entry allows you to enter the raw results as reported by the officials-the athlete's bib number and the time they clocked in a race. It then computes the event's full results. There's more we could add to make this class more complete. But I won't. You can create a list of athletes that are competing in the track and field meeting:"
".event_name is a string with the name of the event. You could use other data types, such as an Enum, but I'll keep this simple here and use a string. .participants is a list containing Athlete instances. These are the athletes participating in this particular event at the track and field meeting. .results contains each athlete's performance. We have choices. The simplest option is to use a list of tuples, where each tuple contains the athlete and the performance."
Define a class representing a track and field event with attributes for event_name (string), participants (list of Athlete instances), and results (list of Result instances or tuples). Provide a way to enter raw official results consisting of an athlete's bib number and their recorded time, and append those to the results collection. Implement a finalise operation that sorts performances by time to compute full placements. Use Python features such as lambda functions and the sort key parameter to order results. Keep the design deliberately simple and object-oriented. Example competitors include Usain Bolt (9.58), Carl Lewis (9.86), and Jesse Owens (10.3).
Read at Thepythoncodingstack
Unable to calculate read time
[
|
]