As a software engineer, you are hired to arrange football players based on  their country and position. You have given all the player’s information in  a tuple called my_tuple. The players are from 3 countries which are Brazil,  Argentina and Germany. They are 2 positions which are “Forward” and  “Midfield” You are given the following nested tuple where each element in the my_tuple  is a tuple consisting of a name and a 4 digit ID. my_tuple = (("Firmino", 1101),("Gabriel", 1201),("Casemiro", 1302),("Fred",  1402),("Messi", 1111),("Aguero", 1211),("Klose", 1121), ("Werner", 1221),  ("Toni", 1322)) Write a python program that will convert this tuple into the following  dictionary using the process described below: Your code should work for all  types of similar tuple if the sample input is changed. Output dictionary (You just have to print the resultant dictionary. No need  to follow the pattern below) { 'Forward':      {      'Brazil': ('Firmino', 'Gabriel'),      'Argentina': ('Messi', 'Aguero'),      'Germany': ('Klose', 'Werner')      } 'Midfielder':      {      'Brazil': ('Casemiro', 'Fred')      'Germany': 'Toni'      } } Here you need to convert the given tuple into the output using the 4 digit  ID. The rules are given below: 1==> Last digit of the ID represents the position. Here      1a--> 1 means Forward      1b--> 2 means Midfield 2==> Third digit of the ID represents the country. Here      2a--> 0 means  Brazil      2b--> 1 means Argentina      2c--> 2 means Germany 3==> If you have multiple players in a category use tuple to store the  multiple names as the value of the nested dictionary 4==> If any country has no player of a particular position, that country  name should not appear as a key in the nested dictionary of that particular  position. For example, Argentina has no midfielder. So Argentina did not  appear under the “Midfield” position. 5==> If your output dictionary’s key value pair sequence is not the same as  the shown output you should not worry about that. However, the key value  pair should be exactly the sam

Np Ms Office 365/Excel 2016 I Ntermed
1st Edition
ISBN:9781337508841
Author:Carey
Publisher:Carey
Chapter8: Working With Advanced Functions
Section: Chapter Questions
Problem 4.4CP
icon
Related questions
Question

As a software engineer, you are hired to arrange football players based on 
their country and position. You have given all the player’s information in 
a tuple called my_tuple. The players are from 3 countries which are Brazil, 
Argentina and Germany. They are 2 positions which are “Forward” and 
“Midfield”

You are given the following nested tuple where each element in the my_tuple 
is a tuple consisting of a name and a 4 digit ID.

my_tuple = (("Firmino", 1101),("Gabriel", 1201),("Casemiro", 1302),("Fred", 
1402),("Messi", 1111),("Aguero", 1211),("Klose", 1121), ("Werner", 1221), 
("Toni", 1322))

Write a python program that will convert this tuple into the following 
dictionary using the process described below: Your code should work for all 
types of similar tuple if the sample input is changed.

Output dictionary (You just have to print the resultant dictionary. No need 
to follow the pattern below)
{
'Forward':
     {
     'Brazil': ('Firmino', 'Gabriel'),
     'Argentina': ('Messi', 'Aguero'),
     'Germany': ('Klose', 'Werner')
     }
'Midfielder':
     {
     'Brazil': ('Casemiro', 'Fred')
     'Germany': 'Toni'
     }
}

Here you need to convert the given tuple into the output using the 4 digit 
ID. The rules are given below:
1==> Last digit of the ID represents the position. Here
     1a--> 1 means Forward
     1b--> 2 means Midfield
2==> Third digit of the ID represents the country. Here
     2a--> 0 means  Brazil
     2b--> 1 means Argentina
     2c--> 2 means Germany
3==> If you have multiple players in a category use tuple to store the 
multiple names as the value of the nested dictionary
4==> If any country has no player of a particular position, that country 
name should not appear as a key in the nested dictionary of that particular 
position. For example, Argentina has no midfielder. So Argentina did not 
appear under the “Midfield” position.
5==> If your output dictionary’s key value pair sequence is not the same as 
the shown output you should not worry about that. However, the key value 
pair should be exactly the sam

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Search Engine
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage