Every year robingnazians (the inhabitants of mbingna, the land of giants), who are as tall as 60 feet h and whose stride
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Every year robingnazians (the inhabitants of mbingna, the land of giants), who are as tall as 60 feet h and whose stride
In the Hanging Gardens of Paradise, Zeus goes for bird watching and keeps track of the different types of mythical birds he sees and the frequency of their sightings. For each type of bird sighted, Zeus maintains a ranking number (initially 0), the species' name, the species' main characteristics, and how many were sighted (frequency). You are given a table, called mythicalBirds, sampled as follows (but your code should work for any non- zero length table): mythicalBirds [[0, 'Adarna', 'Has healing powers", 151, (0, 'Anzu', 'Massive fire breathing bird', 8). [0, 'Bennu', 'Self-creating deity", 51, (0, 'Caladrius', 'White bird with healing powers', 6), [0, 'Chalkydri', 'Heavenly creatures of the Sun', 31, [0, [0, [0, possessions', 101, all birds', 111 10, 'Chol', 'Regenerative bird', 4), Gandabherunda", "Two-headed magical bird', 91, 'Griffin', 'Guards treasure and priceless Garuda', 'The primordial bird and the progenitor of Write a Python program to sort the table in descending order of the frequency of the species' sighting, then add the ranking of the species in the first column, as 1 for most often sighted, 2 for next, etc. Your program should include the following functions: function main that o creates the table mythicalBirds (you can copy the given table to test your program but also try adding a few other entries to make sure your code is working properly for any length table) o prints the original table using the function print Table as described below, the table printing should be formatted and labelled as shown in the sample output o calls the sortByFreq function to sort the table into descending order based on the frequency of the bird's sightings prints the sorted table using the function printTable as described below; the table printing should be formatted and labelled as shown in the sample output function sortByFreq sorts the rows of the given table in descending order of the frequency of the sightings of the birds; you may choose whichever sort algorithm you prefer function print Table prints the given table row by row with formatting as shown in the sample output Sample output: The original Mythical Birds table is as follows: 10, Adarna, Has healing povers, 151 10, Anzo, Massive fire breathing bird. 83 10, Bennu, Self-creating deity, 51 10, Caladriss, white bird with healing powers, 10. Chalkydri, Heavenly creatures of the Sun, 31 10, Chol. Regenerative bird, 41 [0, Gandabherunda, Two-headed magical bird, 91 10. Grittin, Guards treasure and priceless possessions, 10 (0, Garude, The primordial bird and the progenitor of all birds, 23 The sorted and ranked Mythical Birds table, is as follows 11, Adarna, Has healing powers. 151 12, Griffin, Guards treasure and priceless possessions, 201 13. Gandabherunda, Two-headed magical bied. 91 [4, Anzu, Massive fire breathing bird, 15, Caladrius, White bird with healing povers, 16, Bennu, Self-creating deity, 51 17, Chol, Regenerative bird, 41 18, Chalkydri, Heavenly creatures of the Bun, 31 19, Garuda, The primordial bird and the progenitor at all birds, 11
Question his question MAZ QUE You are given a table with information (all in string format, see below) about some of the long-term Canadian prime ministers. Each row of data contains information on a prime minister, in the following order Write a Python program to include functions as follows: function main that uses the functions described below to o . name • political party order number within the list of all prime ministers (eg, 1st, 2nd, etc) number of years served year that they became prime minister for the first time what they are known for average rating . print the name of the most popular prime minister based on the given ratings (with the lowest numbered rating being the most popular) o get all the listed information about a prime minister with a particular election year the election year is to be given by the user) o print the number of prime ministers from each of the three parties (Liberal, Conservative, NDP) by repeatedly calling the function partyCount (see below) function nameOfMost Popular PM that, given the table of data, finds and returns the name of the most popular prime minister based on the average ratings (with the lowest numbered rating being the most popular) function print InformationFor Year that, given the table of information and the year that a prime minister was first elected, finds and prints all the information about that prime minister with appropriate descriptive labels, using the function getLabel to get the individual descriptive labels for each piece of data, based on the position of the data's column in the table • function getLabel that, a given column number, determines and returns the descriptive label for the required information to be printed function partycount which, given the table and the name of the party (Liberal, Conservative, or NDP), counts and returns the number of prime ministers for the given party You are given the following table for testing purposes: note: this information may not be completely accurate table William Lyon Mackenzie King', "Liberal', 10th, 21, 1921, Uniting the English and French populations of Canada', 11, I'Sir Henri Charles Wilfrid Laurier', "Liberal', '7th", "15", 1896', 'Bringing about compromises between English and French Canada, I'Lester B. Pearson', 'Liberal', 14th', '5', 1963", Progressive Social policies', '5'1. Joseph Philippe Pierre Yves Elliott Trudeau", "Liberal', 15th, 15, 1968', 'Reformed Canadal's constitution', '4'1. 13), I'Alexander Mackenzie, Conservative", "2nd', '5', 1882, "Continued the nation-building progranne', Joseph Jacques Jean Chrétien', 'Liberal", "20th, 10, 1993". Pioneered the Clarity Act to avoid anbiguity in future referendum questions, *2*1, I'51: John Alexander Macdonald', 'Conservative', '1st, 19, 1867", "Being the principle architect of Confederation', '3'1. I'Louis St. Laurent", "Liberal, 12th, 19, 1948", "Ovezseeing Canada's expanding international role in the postwar world", ¹61. (Martin Brian Mulroney", "Conservative', 18th, 1, 1984, 'Major economic reforma, 191, ('Sir Robert Laird Borden, Conservative', '8th, 9, 1911, "Leadership of Canada during World War 1, 81, I'Stephen Joseph Harper', 'Conservative', '22nd', '9", 2006. As the first leader of the new Conservative Party of Canada", "11'], 1'John George Diefenbaker", "Conservative', 13th, 16, 1957, Renesbered for his role in the 1959 cancellation of the Avro Arrow project", "14"), (Richard Bedford Bennett", "Conservative', '11th', '5', 1930, Highly criticized response to the Great Depression, as well as the subsequent unemployment relief camps', 12'11 Call the file containing your program, political stats.py.