Let's assume that a player plays a multi-agent game where, every gun has a type: "Sidearms" or "Rifles" or "Sniper Rifles". Here, in every dictionary inside the tuple, the key is the gun name, the first index of the dictionary value is the gun type and the second index of the dictionary value is the kills done by that gun in a certain match. Now, write a Python program that will generate a dictionary from the given tuple of dictionaries: ================================================ Given Tuple 1: ({"Ghost" : ["Sidearms", 3]}, {"Vandal" : ["Rifles", 15]}, {"Sheriff" : ["Sidearms", 5]}, {"Operator": ["Sniper Rifles", 7]}, {"Phantom" : ["Rifles", 10]}) Sample Output 1: {"Sidearms" : ["Ghost","Sheriff", 8], "Rifles" : ["Vandal", "Phantom", 25], "Sniper Rifles" : ["Operator", 7]} Explanation1: Here, in the expected dictionary the keys will be the type of the guns and the values for an individual key will have the gun names and the sum of the kills by those guns in a list. ================================================ Given Tuple 2: ({"Classic" : ["Side Arms", 2]}, {"Guardian" : ["Rifles", 10]}, {"Shorty" : ["Side Arms", 4]}, {"Vandal" : ["Rifles", 20]}) Sample Output 2: {"Sidearms" : ["Classic","Shorty", 6], "Rifles" : ["Guardian", "Vandal", 30]} Explanation 2: Here, the unique gun types are: "Sidearms" and "Rifles", which will be the keys for the output dictionary. For "Side Arms" we get two gun names: "Classic", "Shorty" and the total kills by them is = 2+4 = 6. So, the value for the key "Side Arms" will be ["Classic","Shorty", 6]. And so on.
Let's assume that a player plays a multi-agent game where, every gun has a type: "Sidearms" or "Rifles" or "Sniper Rifles". Here, in every dictionary inside the tuple, the key is the gun name, the first index of the dictionary value is the gun type and the second index of the dictionary value is the kills done by that gun in a certain match. Now, write a Python program that will generate a dictionary from the given tuple of dictionaries: ================================================ Given Tuple 1: ({"Ghost" : ["Sidearms", 3]}, {"Vandal" : ["Rifles", 15]}, {"Sheriff" : ["Sidearms", 5]}, {"Operator": ["Sniper Rifles", 7]}, {"Phantom" : ["Rifles", 10]}) Sample Output 1: {"Sidearms" : ["Ghost","Sheriff", 8], "Rifles" : ["Vandal", "Phantom", 25], "Sniper Rifles" : ["Operator", 7]} Explanation1: Here, in the expected dictionary the keys will be the type of the guns and the values for an individual key will have the gun names and the sum of the kills by those guns in a list. ================================================ Given Tuple 2: ({"Classic" : ["Side Arms", 2]}, {"Guardian" : ["Rifles", 10]}, {"Shorty" : ["Side Arms", 4]}, {"Vandal" : ["Rifles", 20]}) Sample Output 2: {"Sidearms" : ["Classic","Shorty", 6], "Rifles" : ["Guardian", "Vandal", 30]} Explanation 2: Here, the unique gun types are: "Sidearms" and "Rifles", which will be the keys for the output dictionary. For "Side Arms" we get two gun names: "Classic", "Shorty" and the total kills by them is = 2+4 = 6. So, the value for the key "Side Arms" will be ["Classic","Shorty", 6]. And so on.
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...
Related questions
Question
Let's assume that a player plays a multi-agent game where, every gun has a
type: "Sidearms" or "Rifles" or "Sniper Rifles".
Here, in every dictionary inside the tuple, the key is the gun name, the
first index of the dictionary value is the gun type and the second index of
the dictionary value is the kills done by that gun in a certain match.
Now, write a Python program that will generate a dictionary from the given
tuple of dictionaries:
================================================
Given Tuple 1:
({"Ghost" : ["Sidearms", 3]}, {"Vandal" : ["Rifles", 15]}, {"Sheriff" :
["Sidearms", 5]}, {"Operator": ["Sniper Rifles", 7]}, {"Phantom" :
["Rifles", 10]})
Sample Output 1:
{"Sidearms" : ["Ghost","Sheriff", 8], "Rifles" : ["Vandal", "Phantom",
25], "Sniper Rifles" : ["Operator", 7]}
Explanation1:
Here, in the expected dictionary the keys will be the type of the guns and
the values for an individual key will have the gun names and the sum of the
kills by those guns in a list.
================================================
Given Tuple 2:
({"Classic" : ["Side Arms", 2]}, {"Guardian" : ["Rifles", 10]},
{"Shorty" : ["Side Arms", 4]}, {"Vandal" : ["Rifles", 20]})
Sample Output 2:
{"Sidearms" : ["Classic","Shorty", 6], "Rifles" : ["Guardian", "Vandal",
30]}
Explanation 2:
Here, the unique gun types are: "Sidearms" and "Rifles", which will be the
keys for the output dictionary.
For "Side Arms" we get two gun names: "Classic", "Shorty" and the total
kills by them is = 2+4 = 6. So, the value for the key "Side Arms" will be
["Classic","Shorty", 6]. And so on.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Recommended textbooks for you
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
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
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY