Question

In: Computer Science

Exercise: Add Monster Cast Member ------------------------- ### Description In this series of exercises, you will create...

Exercise: Add Monster Cast Member
-------------------------

### Description

In this series of exercises, you will create functions
to create, modify and examine dictionaries that
represent characters in an animated film, and the
cast members who voice the characters. The
keys of the dictionary will be character names.
The values in the dictionary will be voice actor
names.

For this exercise, you will create a function that
adds an entry to a dictionary. They key is a
character name, and the value is the name of the
voice actor.

### Files

* `monsterfunctions.py` : set of functions to work with monster cast dictionaries.

### Function Name

`add_cast_member`

### Parameters

* `monsters`: a dictionary
* `character`: a string, the name of a character
* `cast_member`: a string, the name of an actor

### Action

Adds an entry to `monsters`, using `character` as the
key and `cast_member` as the value.

### Return Value

The modified dictionary.

def create_monster_cast():
d1={}
return d1
def add_cast_member(monsters, character, cast_member):
dict = {
"monsters":monsters,
"character":character,
"cast_member":cast_member
}
return dict

Solutions

Expert Solution

SOLUTION:

The following solution has been provided based on my understanding of the problem. It has been implemented to create a dictionary, add dictionary items and finally print dictionary values.

*** The dictionary representation and function may vary from what is shown in the question****

  • The function create_monster_cast() will create an empty dictionary.
  • The function add_cast_member(monsters, character, cast_member) as shown accepts 3 arguements. The first being the dictionary name, the second being the character name(key) and third cast member name(value).
  • Using character as the key, the value of cast_member is assigned to the dictionary monsters.
  • The modified dictionary is returned.

PROGRAM

# Create an empty dictionary
def create_monster_cast():
    d1 = {}
    return d1

# Add cast to a dictionary
def add_cast_member(monsters, character, cast_member):
    dictionary = monsters
    dictionary[character] = cast_member
    return dictionary

# Create monster dictionary
monsters = create_monster_cast()
# Add Cast to Monster Dictionary
monsters = add_cast_member(monsters, 'James P. "Sulley" Sullivan', 'John Goodman')
monsters = add_cast_member(monsters, 'Michael "Mike" Wazowski', 'Billy Crystal')
monsters = add_cast_member(monsters, 'Boo', 'Mary Gibbs')
monsters = add_cast_member(monsters, 'Randall Boggs', 'Steve Buscemi')
monsters = add_cast_member(monsters, 'Randall Boggs', 'Steve Buscemi')
monsters = add_cast_member(monsters, 'Henry J. Waternoose III', 'James Coburn');
# Print Dictionary values
print('Monster Cast : ')
for key, value in monsters.items():
    print(format(key, "<30"), ': ', end='')
    print(value)

SCREENSHOT

Note:

The list of 6 characters along with their cast have been added to the monster dictionary and data displayed.

Hope this helps.


Related Solutions

PYTHON Exercise: Accelerate Method ------------------------- ### Description In this exercise, you will add to your `Car`...
PYTHON Exercise: Accelerate Method ------------------------- ### Description In this exercise, you will add to your `Car` class a method to accelerate the speed of an instance. ### Class Name `Car` ### Method `accelerate()` ### Parameters * `self` : the `Car` object to use * `delta_speed` : a number, the desired value to add to the speed data member. ### Action Adds `delta_speed` to the speed of the object. If the new speed is too fast, then set the speed to...
Description: In this program, you'll reuse the Monster data type you wrote in LA11A. Then, you'll...
Description: In this program, you'll reuse the Monster data type you wrote in LA11A. Then, you'll write a function that accepts a Monster as an argument by reference, then print the Monster to the screen. Again, this will be structured as a guided multiple choice quiz where you will choose the appropriate code for a program. After you have gotten a perfect score, write out the program and compile and run it to see it in action. Instructions: Choose the...
THIS QUESTION IS BASED UPON JAVA PROGRAMMING. Exercise 1 In this exercise, you will add a...
THIS QUESTION IS BASED UPON JAVA PROGRAMMING. Exercise 1 In this exercise, you will add a method swapNodes to SinglyLinkedList class. This method should swap two nodes node1 and node2 (and not just their contents) given references only to node1 and node2. The new method should check if node1 and node2 are the same nodes, etc. Write the main method to test the swapNodes method. Hint: You may need to traverse the list. Exercise 2 In this exercise, you will...
Create a class DogWalker member List <String>doggies method: void addDog(String name ) //add dog to the...
Create a class DogWalker member List <String>doggies method: void addDog(String name ) //add dog to the List method: void printDogList() //print all dogs in list /* You’ll need an index. Iterate over your list of dog names in a while loop. Use your index to “get” the dog at the current index When you ‘find’ your dog name in the list, print it out */ Method: void findDogUsingWhile(String dogName) /* You’ll need an index. Iterate over your list of dog...
You are a member of a research team that has been asked to create a proposal...
You are a member of a research team that has been asked to create a proposal for a study design to address a potential cholera outbreak in Puerto Rico. The Centers for Disease Control and Prevention is sending a team of epidemiologists to Puerto Rico to investigate cases of cholera associated with Hurricane Maria. As a team member, you are asked to research study design for the upcoming investigation, identifying the advantages and disadvantages of the following four designs as...
function exerciseOne(){ // Exercise One: In this exercise you will create a variable called 'aboutMe' //...
function exerciseOne(){ // Exercise One: In this exercise you will create a variable called 'aboutMe' // This variable should be assigned a new object // In this object create three key:value pairs // The keys should be: 'name', 'city', 'favoriteAnimal' // The values should be strings associated with the keys. // return the variable 'aboutMe' } function exerciseTwo(animal){ // Exercise Two: In this exercise you will be given an object called 'animal' // Create a new variable called 'animalName' //...
In this exercise, the first of a series, we will make connections between the physics you...
In this exercise, the first of a series, we will make connections between the physics you have been learning (in this case, kinematics) and how it is used by people in their work and research. Today we consider an example from kinesiology research, based on a 2000 paper from the Journal of Measurement in Physical Education and Exercise Science (nota bene: you do not have to read this paper, or any of the hyperlinks to follow the exercise – it...
Calculator in Assembly Language (Please add comments to explain your steps) Description: You are responsible to...
Calculator in Assembly Language (Please add comments to explain your steps) Description: You are responsible to implement several assembly functions to perform the simple arithmetic calculations for 2 64-bit integers. These functions will use the C function signature but the main logic within this function should be inline assembly code using the ASM block similar to the assembly example shown in class. Program Specification: 1. long mult ( long op1, long op2 ) - Can’t use the MUL/IMUL instructions, meaning...
Exercises on account of debtors The first exercise: You had the following information during 2012: 1-...
Exercises on account of debtors The first exercise: You had the following information during 2012: 1- The debit balance of 350,000. The balance of provision for doubtful debts is 4000 d. 2- The total sales was 100000D. 30% futures. 3- The future sales returns were 2000 d. 4- Cash receipts from debtors during the year 24700. Upon examining the debtors at the end of the hundredth, it is decided the following: A- Cancellation of a debt due to the current...
2. Describe two exercises and one other strategy (not exercise) that you can undertake to reduce...
2. Describe two exercises and one other strategy (not exercise) that you can undertake to reduce the risk of injury when using a computer. Explain how often you would recommend the exercises are done
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT