Question: NESTED LOOPS IN PYTHON Python only, please! The medal counts for the figure skating competitions at the 2018 Winter Olympics for the top 6 countries

NESTED LOOPS IN PYTHON

NESTED LOOPS IN PYTHON Python only, please! The medal counts for the

Python only, please!

The medal counts for the figure skating competitions at the 2018 Winter Olympics for the top 6 countries are as follows Gold BronzeSilver Medal Medal 2 Medal 3 Country Total Points Canada China Germany Korea Russia U.S.A 15 Write a code to calculate and output the total points for each country. To do that, i. Set up two empty lists to hold the name of the country (lstCountry) and the total points for each country ii Set up a for loop (outer loop) for country information. Inside the outer loop, do the following (lstPoints). These empty lists should be setup before the start of the outer list. Ask the user to enter the name of the country Set up and initialize the accumulator for country total points (countryTotalPoints) Set up and initialize the inner loop (while loop) counter iii. Set up an inner (while) loop to enable the user enter the number of medals in each category: medal 1 is bronze, medal 2 is silver, and medal 3 is gold. You must use only one line of input in the loop for each of meda medal 2, medal 3 iv. Compute the total points for the country based on the following rules: One bronze is worth 1 point, one silver is worth 2 points, while one gold is worth 3 points. The country with the highest total points wins the competition. v. For each country, append the name of the country to IstCountry and the total points to IstPpints (should this be vi. Print the following header: Use escape sequence to accomplish this: print ("Country"+ "t" +Total Points") done inside the inner loop or outside the inner loop?). Country Total Points vii. Set up an entirely new loop (after the outer loop) to print the contents of the lstCountry and IstPoints. The name of the country should be printed in upper case letters. Do you still remember how to use the upper0 function? s"Michael": s.upper) is MICHAEL Your output should look like the following: Country Total Points CANADA 15 CHINA GERMANY 3 KOREA RUSSIA 3 U.S.A RORY 23 15 The country that has the highest points is China Thank you for using my app! Hint: To find the country with the highest points, find the max of the IstPoints, determine the index of the max (refer to our slides on datatypes and operations: pages 14-19); thereafter find the country that occupies that same index position in the IstCountry list

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!