VALORANT is a tactical shooter game where a single match contains multiple rounds between two teams. Given a match information file that contains…

  

 VALORANT is a tactical shooter game where a single match contains multiple rounds between two teams. Given a match information file that contains information on each round (same file format as Question 5!), parse it and return the data as a dictionary. The input file format for each row: Winning Team,#of Surviving Attackers,#of Surviving Defenders,Round Type Example of an input file:Attackers,1,0,EliminatedDefenders,0,3,DefusedDefenders,1,2,Defused Each line of the file represents a single round’s information. It contains information on what team won the round, the number of surviving members for each respective team, and the round win type. The information on each line is separated by commas. Write a function that takes a file of the format given above and returns the dictionary. The output dictionary should have two keys: ‘Attackers’ and ‘Defenders’. The respective values for each key should be a list of tuples, where each tuple is in the format of: (#of surviving members of the winning team, round type)For a single row, only the winning team should have a tuple added to their list in the dictionary. Example (using input from above): Input fileWinning Team (key)# of surviving members of winning teamRound TypeTuple in output value listAttackers,1,0,EliminatedDefenders,0,3,DefusedDefenders,1,2,Defused’Attackers’ ‘Defenders’ ‘Defenders’1 3 2’Eliminated’ ‘Defused’ ‘Defused'(1, ‘Eliminated’) (3, ‘Defused’) (2, ‘Defused’) Output dictionary: {‘Attackers’: [(1, ‘Eliminated’)], ‘Defenders’: [(3, ‘Defused’), (2, ‘Defused’)]} Note that the number of surviving members should be an integer.  For each team, their list of tuples should be in the order in which they first appear in the file (starting from the top).’Attackers’ should always be the first key in the dictionary, with ‘Defenders’ following it. You can assume that the file will only contain ‘Attackers’ or ‘Defenders’ as the team.If the file is empty a dictionary should still be returned with the keys ‘Attackers’ and ‘Defenders’, with their values being empty lists. Hint: Try defining the dictionary for the empty file case first, so then you don’t need to worry about the keys/value lists not existing when trying to add the tuples into the dictionary. Hint: When reading in the file, approach it line-by-line. Remember that order of the elements in each line will be consistent and be separated by commas. The str.split() function may be useful here. Additionally, the str.strip() function may be useful to get rid of any unneeded characters. def parse_match(filepath):    “””    >>> parse_match(‘files/game1.txt’)    {‘Attackers’: [(1, ‘Eliminated’)], ‘Defenders’: [(3, ‘Defused’), (2, ‘Defused’)]}     >>> parse_match(‘files/empty.txt’)    {‘Attackers’: [], ‘Defenders’: []}     >>> parse_match(‘files/game2.txt’)    {‘Attackers’: [(1, ‘Eliminated’), (1, ‘Eliminated’), (0, ‘Eliminated’)], ‘Defenders’: [(3, ‘Defused’), (2, ‘Defused’), (3, ‘Eliminated’), (2, ‘Eliminated’), (1, ‘Defused’), (3, ‘Defused’)]}    “””  Question 6.2:  Using the parsed match information dictionary that we obtained from the previous function (passed in as data), return a list of two tuples containing information on the total number of surviving members on each team for a given round_type.  For example, if the round_type is ‘Eliminated’, sum the total number of surviving members of each team for each ‘Eliminated’ round type contained in the dictionary. Example:Input data: {‘Attackers’: [(1, ‘Eliminated’)], ‘Defenders’: [(3, ‘Defused’), (2, ‘Defused’)]}Input round_type# of surviving Attackers# of surviving DefendersOutput’Eliminated’10[(‘Attackers’, 1), (‘Defenders’, 0)]’Defused’03+2 = 5[(‘Attackers’, 0), (‘Defenders’, 5)]’Nonexistent’00[(‘Attackers’, 0), (‘Defenders’, 0)] The list should have the Attackers tuple as its first element, with the Defenders tuple being the second element. Note that the input round_type may not exist in the given data.  If the function call to parse_match returns a dictionary with an empty list as one of its values or if a team doesn’t have any entries for a given round type, the tuple should still be in the output with a value of 0 for the team.Example: [(‘Attackers’, 0), (‘Defenders’, 0)] def count_members(data, round_type):    “””    >>> data1 = parse_match(‘files/game1.txt’)    >>> count_members(data1, ‘Eliminated’)    [(‘Attackers’, 1), (‘Defenders’, 0)]    >>> count_members(data1, ‘Defused’)    [(‘Attackers’, 0), (‘Defenders’, 5)]    >>> count_members(data1, ‘Nonexistent’)    [(‘Attackers’, 0), (‘Defenders’, 0)]    “”” empty.txt has nothinggame1.txtAttackers,1,0,EliminatedDefenders,0,3,DefusedDefenders,1,2,Defused  game2.txtDefenders,0,3,DefusedDefenders,1,2,DefusedAttackers,1,0,EliminatedDefenders,2,3,EliminatedDefenders,4,2,EliminatedAttackers,1,0,EliminatedDefenders,5,1,DefusedDefenders,10,3,DefusedAttackers,0,0,Eliminated  Computer Science Engineering & Technology Python Programming DSC 20

Don't use plagiarized sources. Get Your Custom Essay on
VALORANT is a tactical shooter game where a single match contains multiple rounds between two teams. Given a match information file that contains…
Just from $13/Page
Order Essay
  

Leave a Reply

Your email address will not be published.

Related Post

Exam Lesson Name: Communicating Effectively; Working in Groups and Teams Exam number: 500028RR Exam Guidelines Exam Instructions Question 10 of 20 :…Exam Lesson Name: Communicating Effectively; Working in Groups and Teams Exam number: 500028RR Exam Guidelines Exam Instructions Question 10 of 20 :…

  please help me answer this question thanks Image transcription textExam Lesson Name: Communicating Effectively; Working in Groups and Teams Exam number: 500028RRExam Guidelines Exam Instructions Question 10 of 20 :

READ MOREREAD MORE
Open chat
💬 Need help?
Hello 👋
Can we help you?