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...

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.
Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here