Define a function that takes in a dictionary as a parameter

Assignment Help Python Programming
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))

Reference no: EM132357087

Questions Cloud

A program that show all of course names and scores on file : Write another program that reads grades.txt. The program should output all of the course names and scores on file, one course per line as shown.
Process for presidential disaster declarations is effective : Do you think the process for Presidential Disaster Declarations is effective, today? What would you change to make these declarations more effective?
Benefits and consequences of technology : Identify one technology that seems to have the greatest potential positive effect on food security. Discuss any potential negative uses of that technology.
How the french revolution differ from american revolution : In what three ways does the French Revolution differ from the American Revolution? Use three specific examples to support your points.
Define a function that takes in a dictionary as a parameter : CS 1301 - Define a function that takes in a dictionary as a parameter. The dictionary maps artists to the number of solo records they have.
Defined roles and responsibilities during natural disasters : According to the textbook, the Federal Disaster Assistance Act of 1950 (P.L. 81-875) defined the roles and responsibilities during natural disasters.
What you can find with a quick google search : Remember, all information discussed in your essay should come from material discussed in this class. Make sure to cite where you got your information.
What are the rules : Explain who owns intellectual property in an employment scenario, for example, when one works for a company. What are the rules? Are they fair? Why or why not?
Police and enforce the copyrights under agreements : Although it might be difficult, how could the trading partners police and enforce the copyrights under their agreements?

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd