Question
Question-2: 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
Question-2: 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started