From the course: Python: Programming Efficiently
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Solution: Analyze Olympic medalist data - Python Tutorial
From the course: Python: Programming Efficiently
Solution: Analyze Olympic medalist data
(upbeat music playing) - [Instructor] After loading the medalist dataset, we find the athletes with the most gold medals, with a straightforward applications of collections counter. We feed it the generator expression that extracts the names of athletes. We call the counter method most common to see those with the most gold around their neck. The best four our Paavo Nurmi, Carla Lewis, Usain Bolt an Ray Ewry. To find the athletes with medals in the most events, we need to collect a set of unique events won by every athlete. A default deque that provides an empty set as default seems appropriate. So we go through the medals to fill up the dict. Adding the event to the set for each athlete. Remember that in Python, you append to a list, but you add to a set. Then we down select the set with a dictionary comprehension that checks the number of events for each athlete. This is almost right, but Usain Bolt and Allyson…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Writing Python efficiently50s
-
(Locked)
Python vs. C4m 40s
-
(Locked)
Design efficient loops7m 3s
-
(Locked)
Comprehensions and generators6m 41s
-
(Locked)
Exploit Python collections7m 14s
-
(Locked)
Write Pythonic code6m 44s
-
(Locked)
Challenge: Analyze Olympic medalist data1m 20s
-
(Locked)
Solution: Analyze Olympic medalist data1m 33s
-
(Locked)
-
-
-
-