Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming language in Python 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

Programming language in Python

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 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. 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: num1 = 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_2

Step: 3

blur-text-image_3

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

Question

1.who the father of Ayurveda? 2. Who the father of taxonomy?

Answered: 1 week ago

Question

Commen Name with scientific name Tiger - Wolf- Lion- Cat- Dog-

Answered: 1 week ago