As a programmer, you want to create a function to arrange the names of the actors and actresses based on their country. You will be given all the required information in a dictionary called my_dictionary which shall be passed as argument to the function call. Assume, the actors/actresses are either American, Korean or German (from 3 countries only). The names are further categorized under "Actors" and "Actresses". You are given the following dictionary where you have a nested dictionary containing a tuple. my_dictionary = {'American': {'Actors": ("Tom Cruise', "Leonardo DiCaprio'), 'Actresses": ('Scarlett Johansson', "Angelina Jolie')}, "Korean": {'Actors": ('Lee in-ho', 'Song Joong-ki", "Choi Jin-hyuk')}, "German": {'Actors": ('David Kross', "Michael Fassbender), 'Actresses":('Diana Kruger)}} Write a python function that will take this dictionary as an argument in a function call which will convert this dictionary into the following tuple and return it. [Hint. You might need to use 3 nested loops.] Output tuple(You just have to print the resultant tuple.): ((Tom Cruise', 11010), ('Leonardo DiCaprio', 11017), (Scarlett Johansson', 12018), ('Angelina Jolie', 12014), ('Lee in-ho', 21009), ('Song Joong-ki"', 21013), ('Choi Jin-hyuk', 21013), ('David Kross', 31011), ('Michael Fassbender, 31018), ('Diana Kruger, 32012)) The output tuple consists of tuples as the elements. Each nested tuple has the name of the actoriactress (string) and an ID (integer) which is to be generated using the described process below. 1==> First Digit of the ID: 1a-> American is represented with 1 1b-> Korean is represented with 2 1c-> German is represented with 3 2==> Second digit of the ID represents type. Here 2a--> 1 means Actors 2b-> 2 means Actresses 3==>The last 3 digits of the Id is basically the length of the names of the actors/actresses including any spaces in between the names. For example, the length of the name "Tom Cruise" is 10 and so the last 3 digits are 010. For simplicity, you can consider that the length of the names of the actors/actresses will not be greater than 99. 4==> Do not worry about the uniqueness of these ids in the output. They do not have to be unique.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

using python..............

As a programmer, you want to create a function to arrange the names of the
actors and actresses based on their country. You will be given all the
required information in a dictionary called my_dictionary which shall be
passed as argument to the function call. Assume, the actors/actresses are
either American, Korean or German (from 3 countries only). The names are
further categorized under "Actors" and "Actresses".
You are given the following dictionary where you have a nested dictionary
containing a tuple.
my_dictionary = {'American': {'Actors': ('Tom Cruise', "Leonardo
DiCaprio'), 'Actresses': ("Scarlett Johansson', 'Angelina
Jolie')}, "Korean': {'Actors': ('Lee in-ho', 'Song Joong-ki","Choi
Jin-hyuk')}, 'German": {'Actors": ('David Kross', 'Michael
Fassbender'), 'Actresses":('Diana Kruger)}}
Write a python function that will take this dictionary as an argument in a
function call which will convert this dictionary into the following tuple
and return it.
[Hint: You might need to use 3 nested loops.]
Output tuple(You just have to print the resultant tuple.):
((Tom Cruise', 11010), ('Leonardo DiCaprio', 11017), ('Scarlett
Johansson', 12018), ('Angelina Jolie', 12014), ('Lee in-ho', 21009), ('Song
Joong-ki', 21013), ('Choi Jin-hyuk', 21013), ('David Kross', 31011),
('Michael Fassbender', 31018), ('Diana Kruger', 32012)
The output tuple consists of tuples as the elements. Each nested tuple has
the name of the actor/actress (string) and an ID (integer) which is to be
generated using the described process below.
1==> First Digit of the ID:
1a-> American is represented with 1
1b--> Korean is represented with 2
1c-> German is represented with 3
2==> Second digit of the ID represents type. Here
2a--> 1 means Actors
2b--> 2 means Actresses
3==>The last 3 digits of the Id is basically the length of the names of the
actors/actresses including any spaces in between the names. For example,
the length of the name "Tom Cruise" is 10 and so the last 3 digits are 010.
For simplicity, you can consider that the length of the names of the
actors/actresses will not be greater than 99.
4==> Do not worry about the uniqueness of these ids in the output. They do
not have to be unique.
Transcribed Image Text:As a programmer, you want to create a function to arrange the names of the actors and actresses based on their country. You will be given all the required information in a dictionary called my_dictionary which shall be passed as argument to the function call. Assume, the actors/actresses are either American, Korean or German (from 3 countries only). The names are further categorized under "Actors" and "Actresses". You are given the following dictionary where you have a nested dictionary containing a tuple. my_dictionary = {'American': {'Actors': ('Tom Cruise', "Leonardo DiCaprio'), 'Actresses': ("Scarlett Johansson', 'Angelina Jolie')}, "Korean': {'Actors': ('Lee in-ho', 'Song Joong-ki","Choi Jin-hyuk')}, 'German": {'Actors": ('David Kross', 'Michael Fassbender'), 'Actresses":('Diana Kruger)}} Write a python function that will take this dictionary as an argument in a function call which will convert this dictionary into the following tuple and return it. [Hint: You might need to use 3 nested loops.] Output tuple(You just have to print the resultant tuple.): ((Tom Cruise', 11010), ('Leonardo DiCaprio', 11017), ('Scarlett Johansson', 12018), ('Angelina Jolie', 12014), ('Lee in-ho', 21009), ('Song Joong-ki', 21013), ('Choi Jin-hyuk', 21013), ('David Kross', 31011), ('Michael Fassbender', 31018), ('Diana Kruger', 32012) The output tuple consists of tuples as the elements. Each nested tuple has the name of the actor/actress (string) and an ID (integer) which is to be generated using the described process below. 1==> First Digit of the ID: 1a-> American is represented with 1 1b--> Korean is represented with 2 1c-> German is represented with 3 2==> Second digit of the ID represents type. Here 2a--> 1 means Actors 2b--> 2 means Actresses 3==>The last 3 digits of the Id is basically the length of the names of the actors/actresses including any spaces in between the names. For example, the length of the name "Tom Cruise" is 10 and so the last 3 digits are 010. For simplicity, you can consider that the length of the names of the actors/actresses will not be greater than 99. 4==> Do not worry about the uniqueness of these ids in the output. They do not have to be unique.
Remember: Your code should work for all types of similar dictionaries if
the sample dictionary is changed.
Transcribed Image Text:Remember: Your code should work for all types of similar dictionaries if the sample dictionary is changed.
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY