Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Test: a_list = ['Bay of Plenty region', 'Gisborne region'] a_dict = {2020: [('Bay of Plenty region', 4005), ('Gisborne region', 663)], 2021: [('Bay of Plenty region',

image text in transcribed

Test:

a_list = ['Bay of Plenty region', 'Gisborne region'] a_dict = {2020: [('Bay of Plenty region', 4005), ('Gisborne region', 663)], 2021: [('Bay of Plenty region', 4173), ('Gisborne region', 675)], 2022: [('Bay of Plenty region', 4257), ('Gisborne region', 723)]} print_table("Years", a_list , a_dict)

The output should be:

Years|Bay of Plenty region |Gisborne region | -------------------------------------------------- 2020 |4005 |663 | 2021 |4173 |675 | 2022 |4257 |723 |

(The output should be EXACTLY THE SAME as above, including the white spaces and all the things aligning left, thank you very much)

Define a function named print_table(name, column_names, a_dict) which takes a table name, a list of column names and a dictionary of data as parameters and prints the table as shown in the examples below. For example, if the table name is 'Regions', the column names list is [ 'Auckland region', 'Northland region'] and the dictionary is: \{'Northland region': [(2021,2262),(2022,2367)], 'Auckland region': [(2021,20520), (202 then the function prints the table below: produces: Note: - You can assume that all parameters are valid. - The width of the first column (i.e. label) in the table is obtained by calling the get_longest_string_length ( ) function that you wrote in Q6. You can assume that the function is given. - The width of the remaining columns in the table is obtained by calling the get_longest_column_length( ) function that you wrote in Q7. You can assume that the function is given. - You may find the f-string helpful. For example: use "\{name

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

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

=+c) Which residual contributes least to that sum?

Answered: 1 week ago