The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 1 Day Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Function Name:artistMishap (15 points)
Description:Define a function that takes in a dictionary as a parameter. The dictionary maps artists to the number of solo records they have (not actually correct). Your function should update each of the solo records according to the following criteria:
•If the number is odd:
oIf the number is a multiple of 7 then increment the number by 7
oIf the number is a multiple of 5 then decrease the number by a factor
of 5 (keep it as an integer)
oElse if the number is a multiple of 3 then decrement the number by 3
•If the number is even:
oIf the number is a multiple of 7 then decrement the number by 7
oElse if the number is a multiple of 5 then increment the number by 5 oIf a number is a multiple of 3 then increment the number by a factor
of 3
oAlwayssquare the number
Note: Some number may be a multiple of any combination of 3, 5, or 7. Also, the numbers in your dictionary should and will change as you go through the different cases. It is your job to make sure that number is only changed according to the correct criteria (i.e. if the number is 105 that means it is odd and a multiple of 3, 5 and 7. However we willonlyincrement the number by 7 because the updated value in the dictionary after we check to see if it is a multiple of 7 is now112,which is not a multiple of either 5 or 3).
After updating the values in the dictionary, your function should return a tuple of tuples. The first tuple contains the artist with the minimum number of solo records, and the second tuple contains the artist with the maximum number of solo records. Each of the tuples should be represented as (artist, number_of_records), and both of these tuples should be placed within one tuple.
Parameter(s):
1. A dictionary. The keys are strings and the values are integers. a. Thekeysaretheartists.
b. The values are the corresponding artists’ solo records.
CS 1301 – Homework 5: Tuple and Dictionary Manipulation – Fall 2016
Return Value:A tuple containing two tuples. Thefirst tupleis the artist with the minimumnumber of solo records. Thesecond tupleis the artist with the maximumnumber of solo records. Each of the tuples has theartist(as astring) as thefirst elementandthe number of solo records(as aninteger) as thesecond element.
Example(s):
>>> artists = {"Shakira": 65, "Carlos Vivez": 42, "Juanes": 38, "Neon Trees": 30,
"Walk the Moon": 15, "Kacey Musgraves": 7, "Justin Timberlake": 63, "Michael Jackson": 70, "Michael Buble": 35, "Papa Roach": 26, "Disturbed": 21, "Lil Jon": 30}
>>> print(artistMishap(artists))
(('Walk the Moon', 3), ('Michael Jackson', 35721))
Hel-----------lo -----------Sir-----------/Ma-----------dam----------- Â----------- -----------Â ----------- Â ----------- T-----------han-----------k Y-----------ou -----------for----------- us-----------ing----------- ou-----------r w-----------ebs-----------ite----------- an-----------d a-----------cqu-----------isi-----------tio-----------n o-----------f m-----------y p-----------ost-----------ed -----------sol-----------uti-----------on.----------- Pl-----------eas-----------e p-----------ing----------- me----------- on----------- ch-----------at -----------I a-----------m o-----------nli-----------ne -----------or -----------inb-----------ox -----------me -----------a m-----------ess-----------age-----------