Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use python programming 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

use python programming

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

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 lastline 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. CLUE: Use nested curly brackets with a variable in it to set the minimum number of characters of a string with a variable. [lecture note: String Format-Part2] Given: numl - 123 num2 - 53 stri, str2 and str3 will be identical. w1 - 6 # column width w2 - 4 # column width stri - "!{0:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions