Reference no: EM132357087
Python Programming Question
Function Name:
artistMishap
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:
o If the number is a multiple of 7 then increment the number by 7
o If the number is a multiple of 5 then decrease the number by a factorof 5 (keep it as an integer)
o Else if the number is a multiple of 3 then decrement the number by 3
• If the number is even:
o If the number is a multiple of 7 then decrement the number by 7
o Else if the number is a multiple of 5 then increment the number by 5 o If a number is a multiple of 3 then increment the number by a factorof 3
o Always square 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 will only increment the number by 7 because the updated value in the dictionary after we check to see if it is a multiple of 7 is now 112, 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.
Return Value: A tuple containing two tuples. The first tuple is the artist with the minimum number of solo records. The second tuple is the artist with the maximum number of solo records. Each of the tuples has the artist (as a string) as the first element and the number of solo records (as an integer) as the second 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))