Question: Python pls inputs dictz= { 'Chealsea': [('Ings', 30, 40), ('Dele' , 20, 50), ('Ings',-10, 60), ('Azur', 20, 55)], 'Barca': [('Ings', 20, 40), ('Ings',-10, 45), ('Ink',
Python pls
inputs
dictz= { 'Chealsea': [('Ings', 30, 40), ('Dele' , 20, 50), ('Ings',-10, 60), ('Azur', 20, 55)], 'Barca': [('Ings', 20, 40), ('Ings',-10, 45), ('Ink', 40, 30), ('Ings',-10, 35)], 'Atlanta': [('Ings', 20, 10), ('Dele', 10, 50), ('Azur', 80, 80), ('Dele', -10, 55)], 'Derby': [('Azur', 40, 80), ('Azur', 40, 85), ('Azur',-40, 90)] }
1) Create a function call def one_return_line(dict1): This function takes a dictionary and returns the list of names of people that have a total number of products. However, you only use one "RETURN" statement.
def one_return_line(dict1):
#You can only use one return statement
#Calculation
#Chealsea = 30+20+|-10|+20 = 80
#Derby = 40+40+|-40| = 120
#If two numbers are same, the list sort by alphabetical order
#Try not to use indexing tuple object
output = ['Atlanta', 'Derby', 'Barca', 'Chealsea']
2) Create a function call def one_return_state(dict1): This function takes a dictionary and returns a list of players' name and their values. However, you only use one "RETURN" statement.
def one_return_state(dict1):
#You can only use one return statement
#Calculation
#Try not to use indexing tuple object
#Ings= 30+|-10|+20+|-10|+|-10|+20 = 100
#Azur= 20+80+40+40+|-40| = 220
#If two numbers are same, the list sort by alphabetical order
Output = [('Azur',220), ('Ings',100), ('Dele',40), ('Ink',40)].
Remember One Line return statements only for each function!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
