ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 22 May 2017 My Price 8.00

Python Programming Question

Microsoft Word - CS 1301 – Homework 5.docx

Python Programming Question 

 

Function Name: updateNetworks (20 points)

Description: Define a function that takes in a dictionary and a list of tuples as parameters. The dictionary maps networks to a list of TV shows on that network. Each of the tuples contains a network and a TV show. Your function should update the networks dictionary using the tuples according to the following guidelines. If the network in the tuple is not in the dictionary, then you should add it to your dictionary with the value being a list of that networks’ TV show. If your network is in the dictionary, then if the TV show is not in that networks’ list of TV shows, then it needs to add the TV show to the list of TV shows for that corresponding

CS 1301 – Homework 5: Tuple and Dictionary Manipulation – Fall 2016

 

network. Otherwise, if your network is in your dictionary and the TV show is in that networks’ list of TV shows, then you should delete that TV show from the list of networks. You will then return the updated dictionary.

Parameter(s):

1. A dictionary. The keys are strings and the values are lists of strings. The list may be empty.

a. Thekeysarethenetworks.

b. The values are the corresponding networks’ TV shows. 2. A list of tuples. Each tuple has two elements, both strings.

a. Thefirstelementofeachtupleisanetwork
b. The second element of each tuple is a TV show.

Return Value: The original dictionary with the updated values.

Example(s):

>>> networks = {"Netflix": ["Daredevil"], "ABC": [],

"CBS": ["The Big Bang Theory", "Two and a Half Men"], "NBC": ["30 Rock", "Parks and Recreation", "The Office"], "HBO": ["Last Week Tonight"]}

>>> tv_shows = [("Netflix", "Luke Cage"), ("Netflix", "Stranger Things"), ("The CW", "Jane the Virgin"), ("CBS", "Two and a Half Men"), ("ABC", "Fresh Off the Boat"), ("NBC", "Parks and Recreation"), ("NBC", "The Office"), ("NBC", "30 Rock"),

("The CW", "Pretty Little Liars")]
>>> print(updateNetworks(networks, tv_shows))
{'The CW': ['Jane the Virgin', 'Pretty Little Liars'], 'ABC': ['Fresh Off the Boat'], 'HBO': ['Last Week Tonight'], 'CBS': ['The Big Bang Theory'], 'Netflix': ['Daredevil', 'Luke Cage', 'Stranger Things'], 'NBC': []}

Answers

(11)
Status NEW Posted 22 May 2017 04:05 AM My Price 8.00

-----------

Attachments

file 1495428215-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)