Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Urgent!! Python Question Q6. Write the following function: Function name get_covid_report Parameter(s) argument(s) 1. An instance of Continent. Each instance of the class Continent has
Urgent!! Python Question
Q6. Write the following function: Function name get_covid_report Parameter(s) argument(s) 1. An instance of Continent. Each instance of the class Continent has the following instance attributes name: str stats: dict(str, float] The stats instance attribute has country names as keys and the values are the number of Covid-19 cases per 1000 capita. You may assume the values are valid numbers and have at most 1 decimal place. The definition of the Continent class is available in the submission template. A str, formatted as described below Return value Error handling None. The function must not raise any exceptions. Detail Description Continent name is left aligned All lines, except the first must be of equal length, inclusive of white spaces Europe France: 3.7 Italy: 2.9 Spain: 3.2 Second last line consists of dashes with no space in between. It should be the same length as all other lines, except the first line Country names are right aligned Total cases: 9.8 Colons must be aligned with a minimum Number of cases are right aligned space between the number and the colon formatted to 1 decimal places See next page for text. Don't give up, some marks will be given if some of the criteria are met. Detailed description Note: The function should not write to stdout i.e. do not use print(). The contents of the returned str are as follows: 1. First line shows the Continent's name 2. For each entry in the Continent's stats dictionary: 1. Add a line showing the country's name, followed by the separator": "(1 colon, 1 whitespace), and the number of Covid-19 cases 3. The penultimate (second-to-last) line is a divider consisting a series of dashes (-) 4. The last line shows "Total cases", followed by the separator ":"(1 colon, 1 space) and the continent's total number of cases The formatting of the returned str is as follows: 1. The colons should be aligned i.e. the colons should be in the same position in each line 2. The countries' names should be right-justified 3. The grades should be formatted to one decimal place and right- justified 4. On the final line, "Total cases" is right justified 5. On the final line, the total number of cases is formatted to one decimal place and right-justified 6. All lines, except the first line, should have the same length (including whitespaces) 7. The penultimate (second-to-last) line should be the same length as all other lines, excluding the first line. 8. Do not insert any unnecessary whitespace 9. Your str must include newlines where appropriate. Detailed description Note: The function should not write to stdout i.e. do not use print(). The contents of the returned str are as follows: 1. First line shows the Continent's name 2. For each entry in the Continent's stats dictionary: 1. Add a line showing the country's name, followed by the separator": "(1 colon, 1 whitespace), and the number of Covid-19 cases 3. The penultimate (second-to-last) line is a divider consisting a series of dashes (-) 4. The last line shows "Total cases", followed by the separator ":"(1 colon, 1 space) and the continent's total number of cases The formatting of the returned str is as follows: 1. The colons should be aligned i.e. the colons should be in the same position in each line 2. The countries' names should be right-justified 3. The grades should be formatted to one decimal place and right- justified 4. On the final line, "Total cases" is right justified 5. On the final line, the total number of cases is formatted to one decimal place and right-justified 6. All lines, except the first line, should have the same length (including whitespaces) 7. The penultimate (second-to-last) line should be the same length as all other lines, excluding the first line. 8. Do not insert any unnecessary whitespace 9. Your str must include newlines where appropriate. Example usage 2 asia - Continent "Asia", { "India": 11.1, "Philippines": 0.6, } ) print(get_covid_report(asia)) Example usage 2 Asia output India: 11.1 Philippines: 0.6 Total cases: 11.7 Example usage 3 na = Continent "North America", { "Dominican Republic": 0.2, " Cannada": 0.9, "Mexico": 2.1, } > print(get_covid_report(na)) Example usage 3 output North America Dominican Republic: 0.2 Canada: 0.9 Mexico: 2.1 Total cases: 3.2Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started