Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python : must work for all cases not just test cases Function name: pair_rivals Parameters: A dictionary of one character as the key paired to

Python : must work for all cases not just test cases image text in transcribed
Function name: pair_rivals Parameters: A dictionary of one character as the key paired to one character as his/her rival. The other dictionary will also contain characters as keys and their rival as the values. Assume that valid arguments will always be passed in. Returns: A dictionary of tuple values paired to a boolean (either True or False) Description: As a movie/TV show fanatic you suddenly have the impulse to write a function that pairs rivals with each other. In this function you will take in two dictionary arguments, and return a new dictionary. Both parameters will have one string keys paired to one string values. Each key will represent a certain character and the value will be the rival of that character. If one character's rival in the first dictionary is that rival's rival in any of the dictionaries, add a tuple of both names as a key (first, second) in a new dictionary, paired to True as its value. In other words, only add it into the new dictionary if "character": "rival" in one is found as "rival":"character" somewhere. Add in the order of how it appears the first time. Note/Hint You may use TrylExcept, and you may use list) casting for this function Test cases one ("Naruto": "Sasuke", "Aang": "Zuko", "Ash": "Gary" >>two("Zuko": Aang", "Batman" "Joker") rivals1 pair_rivals(one, two) > print (rivals1) (C'Aang, 'Zuko): True) one ("Rick": "Evil Morty", "Spiderman": "Venom" "Dora": "Swiper") >to ("Evil Morty": "Morty", "Swiper": "Dora") >rivals2 pair_rivals(one, two) print (rivals2) 'Dora, Swiper): True)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2000 Database Design

Authors: Louis Davidson

1st Edition

1861004761, 978-1861004765

More Books

Students also viewed these Databases questions

Question

List operations to be performed on directories?

Answered: 1 week ago

Question

Perform same-size (common-sized) analysis of an income statement.

Answered: 1 week ago

Question

How many multiples of 4 are there between 10 and 250?

Answered: 1 week ago

Question

How many three-digit numbers are divisible by 7?

Answered: 1 week ago

Question

What is Indian Polity and Governance ?

Answered: 1 week ago

Question

Are these written ground rules?

Answered: 1 week ago

Question

Have ground rules been established for the team?

Answered: 1 week ago

Question

a. How are members selected to join the team?

Answered: 1 week ago