Write code to find the name of the first Pokemon with the maxmum number of base...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write code to find the name of the first Pokemon with the maxmum number of base hit points (hp). Remember that you will need to iterate through each element of the list, and each element is a dictionary which has various keys including hp and name. Update (2023-02-17): There are two Pokemon with maximum hit points; find the first one. For extra credit (5 points), find both names without iterating through the list more than once. 2. Generation Counts (10 pts) Write code to create a new dictionary generation counts that stores the counts of each generation in the dataset. 3. Mean Weights by Primary Type (15 pts) Write code to create a new dictionary primary_weights that stores the mean weight of all pokemon with the same primary type. Remember that the mean is the sum of all values divided by the number of values. Hints • Consider creating a dictionary mapping primary type to a list of weights first, and then compute the mean from each list. • Some pokemon have unknown weights. In this case, weight kg is set to None. Make sure to exclude them from mean computations. 4. Filter by Hit Points (15 pts) Write a function filter_hp that takes three parameters, data, min_hp and max_hp, and returns a sorted list of tuples of those pokemon whose base hit points (hp) is within the range min_hp <= hp <= max_hp. The first entry in each tuple should be the number of hit points of the pokemon, and the second entry is its name. Set the default parameter values of min_hp to 1 and max hp to 255. The data parameter will be passed the dataset (the global data). For example, filter_hp(data, 2e, 25) would return [(20.0, Duskull'), (20.0, "Feebas), (29.0, "Magikarp'), (20.0, "Mime Jr.'), (20.8, "Pichu'), (20.0, "Shuckle'), (25.0, "Abra'), (25.0, "Blipbug'), (25.0, "Magnemite'), (25.0, Wimpod")] Hints • Remember that we can sort values of a list in two ways. • Tuples will be sorted by first comparing their first element, then second element, and so on. Write code to find the name of the first Pokemon with the maxmum number of base hit points (hp). Remember that you will need to iterate through each element of the list, and each element is a dictionary which has various keys including hp and name. Update (2023-02-17): There are two Pokemon with maximum hit points; find the first one. For extra credit (5 points), find both names without iterating through the list more than once. 2. Generation Counts (10 pts) Write code to create a new dictionary generation counts that stores the counts of each generation in the dataset. 3. Mean Weights by Primary Type (15 pts) Write code to create a new dictionary primary_weights that stores the mean weight of all pokemon with the same primary type. Remember that the mean is the sum of all values divided by the number of values. Hints • Consider creating a dictionary mapping primary type to a list of weights first, and then compute the mean from each list. • Some pokemon have unknown weights. In this case, weight kg is set to None. Make sure to exclude them from mean computations. 4. Filter by Hit Points (15 pts) Write a function filter_hp that takes three parameters, data, min_hp and max_hp, and returns a sorted list of tuples of those pokemon whose base hit points (hp) is within the range min_hp <= hp <= max_hp. The first entry in each tuple should be the number of hit points of the pokemon, and the second entry is its name. Set the default parameter values of min_hp to 1 and max hp to 255. The data parameter will be passed the dataset (the global data). For example, filter_hp(data, 2e, 25) would return [(20.0, Duskull'), (20.0, "Feebas), (29.0, "Magikarp'), (20.0, "Mime Jr.'), (20.8, "Pichu'), (20.0, "Shuckle'), (25.0, "Abra'), (25.0, "Blipbug'), (25.0, "Magnemite'), (25.0, Wimpod")] Hints • Remember that we can sort values of a list in two ways. • Tuples will be sorted by first comparing their first element, then second element, and so on.
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Howard Corp. purchased an asset for $ 6 0 0 , 0 0 0 on Jan. 1 . The estimated salvage value is $ 4 0 , 0 0 0 , and the estimated useful life is 8 years. The double - declining balance method is used...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
The Crazy Eddie fraud may appear smaller and gentler than the massive billion-dollar frauds exposed in recent times, such as Bernie Madoffs Ponzi scheme, frauds in the subprime mortgage market, the...
-
The curve described by the cable of the suspension bridge shown in Figure 8.70 is given by where x is the distance measured from one end of the bridge. What is the length of the cable (see Example...
-
Knowing that P = 822 N and Q = 0, determine for the frame and loading shown (a) The reaction at D, (b) The force in member BF. 320 mm 210 mm -240 mm 450 mm
-
Restate each of the following question components of the issue in a persuasive manner: a. should the evidence be suppressed when . . .? In the case, the police failed to obtain a search warrant prior...
-
Based on your experiences in college, draw and label a conceptual model that shows the factors that lead to your satisfaction (or dissatisfaction) with a course?
-
The balance sheet of Kishwaukee Corporation as of December 31, 2014, is as follows. Note 1: Buildings are stated at cost, except for one building that was recorded at appraised value. The excess of...
-
Two lakes are located on the same river, as shown in Figure 11-6. A is upstream of B. Water flows into A at a rate SA; it evaporates from A at a rate EA and from B at a rate EB. A tributary flows...
-
Olde World Windows and Doors is a manufacturer of steel windows and doors for both residential and commercial applications. The following problems are decisions that senior management faces in...
-
On July 10, 2023, Oriole Ltd. sold GPS systems to retailers on account for a selling price of $900,000 (cost $720,000). Oriole grants the right to return systems that do not sell in three months...
-
How do advancements in molecular biology, genomics, and systems biology deepen our understanding of the genetic determinants, molecular pathways, and regulatory networks governing respiratory...
-
How do various respiratory disorders such as chronic obstructive pulmonary disease (COPD), asthma, and interstitial lung diseases perturb the normal physiological processes of ventilation, gas...
-
How do respiratory substrates such as glucose, fatty acids, and amino acids undergo intricate catabolic processes within the cellular milieu, culminating in the generation of high-energy...
-
A large fast-food restaurant is having a promotional game where game pieces can be found on various products. Customers can win food or cash prizes. According to the company, the probability of...
-
Can you elucidate the intricate interplay between aerobic respiration and anaerobic metabolism, highlighting their respective biochemical pathways and the discernible disparities in energy yield per...
-
What are the modifications observed in birds that help them to fly?
-
(a) Find the equation of the tangent line to f(x) = x 3 at the point where x = 2. (b) Graph the tangent line and the function on the same axes. If the tangent line is used to estimate values of the...
-
Leslie and Leon Lazo are married and file a joint return for 2012. Leslie's Social Security number is 466-47-3311 and Leon's is 467-74-4451. They live at 143 Snapdragon Drive, Reno, NV 82102. For...
-
Mike purchases a heavy-duty truck (5-year class recovery property) for his delivery service on April 30, 2012. The truck is not considered a passenger automobile for purposes of the listed property...
-
Carl and Jenny adopt a Russian orphan. The adoption takes 2 years and two trips to Russia and is final in 2012. They pay $6,000 in 2011 and $7,500 in 2012 of qualified adoption expenses, and have AGI...
-
Explain how the financial manager might use industry norms in the design of the companys financing mix.
-
You have developed the following income statement for Sing-Tel Corporation. It represents the most recent years operations, which ended yesterday. Your supervisor in the controllers office has just...
-
Financial data for three corporations are displayed here. MEASURE FIRM FIRM FIRM INDUSTRY A B C NORM Debt ratio 21% 24% 39% 21% Times interest 7.5 10.2 7.0 9.1 times earned times times times...
Study smarter with the SolutionInn App