Question

In: Computer Science

Python pls Create a function party_freq(dicto:dict): this function returns a list inside tuple that how many...

Python pls

Create a function party_freq(dicto:dict): this function returns a list inside tuple that how many times each person party in the day.

For example

def party_freq(dicto:dict) -> [(str,{(int,int,int): int})]:

#code here

input

dict1 ={'fire1': {(2000,5,20,480) : ('Aaron', 25, 300, ( 0, 300)),
(2000,5,20,720) : ('Baily', 45, 1500, (1500,500)),
(2000,5,21,490) : ('Aaron', 35, 500, (1300,500)) },
'fire2': {(2000,5,20,810) : ('Baily', 45, 1400, (600,1600)),
(2000,5,20,930) : ('Baily', 43, 1800, ( 0, 0)) }}

output

[('Aaron', {(2000,5,20): 1, (2000,5,21): 1}), ('Baily', {(2000,5,20): 3})]

Solutions

Expert Solution

import typing
def party_freq(dicto:dict) -> [(str,{(int,int,int): int})]:
data=[]
for i in dicto:
for day in dicto[i]:
date=(day[0],day[1],day[2])
names=dicto[i][day]
name=names[0]
found=False
for j in data:
if j[0]==name:
found=True
if date in j[1]:
j[1][date]+=1
else:
j[1][date]=1
if not found:
data.append((name,{date:1}))
return data


Related Solutions

Python pls create a function called search_position. This function returns a list. team1 = {'Fiora': {'Top':...
Python pls create a function called search_position. This function returns a list. team1 = {'Fiora': {'Top': 1, 'Mid': 4, 'Bottom': 3},'Olaf': {'Top': 3, 'Mid': 2, 'Support': 4},'Yasuo': {'Mid': 2, 'Top': 5},'Shaco': {'Jungle': 4, 'Top': 2, 'Mid': 1}} def search_position(team1): returns [(5, [('Top', ['Yasuo'])]), (4, [('Mid', ['Fiora']), ('Support',['Olaf']), ('Jungle',['Shaco'])])   (3, [('Bottom', ['Fiora']), ('Top', ['Olaf'])]), (2, [('Mid', ['Olaf','Yasuo']), ('Top', ['Shaco'])]), (1, [('Mid', ['Shaco'])])]
Python pls create a function called search_position. This function returns a dictionary. team1 = {'Fiora': {'Top':...
Python pls create a function called search_position. This function returns a dictionary. team1 = {'Fiora': {'Top': 1, 'Mid': 4, 'Bottom': 3},'Olaf': {'Top': 3, 'Mid': 2, 'Support': 4},'Yasuo': {'Mid': 2, 'Top': 5},'Shaco': {'Jungle': 4, 'Top': 2, 'Mid': 1}} def search_position(team1): should return {'Top': {'Fiora': 1, 'Yasuo':5,'Olaf':3,'Shaco':}, 'Jungle': {'Shaco': 4}, 'Mid': {'Yasuo', 2, 'Fiora': 4,'Olaf':2}, 'Bottom': {'Fiora': 3}, 'Support': {'Olaf': 4}} *******IMPORTANT*************** The result should be alphabetical order.
Create a program/function using PYTHON that takes cents and returns to the customer how MANY coins...
Create a program/function using PYTHON that takes cents and returns to the customer how MANY coins it takes to make the change... Ex. if the change owed is 50 cents then return a 2 (for two quarters) if the change owed is 10 cents then return a 1 (for one dime) AGAIN please write this in java and please provide EXPLANATION of answer
Python pls Create a function dict_sum. This function takes a dictionary and sums up the values...
Python pls Create a function dict_sum. This function takes a dictionary and sums up the values in the dictionary. For example: dict1 = {1: {'una': 5, 'dos': 7, 'tres': 9, 'quar' : 11}, 2: {'dos':2, 'quar':4}, 3:{'una': 3, 'tres': 5}, 4:{'cin': 6}, 5:{'tres': 7 , 'cin': 8}} dict2 = {300:{'s': 300}, 400:{'s': 100, 'g': 100, 'p': 100}, 500: {'s': 50 ,'m': 400, 'p':30, 'i': 50}, 600: {'s': 40, 'i': 400}, 700: {'m': 100, 'p': 50}} def dict_sum(db): should give output...
create a function that sorted tuple by the second values of each tuple. If the values...
create a function that sorted tuple by the second values of each tuple. If the values are the same, sorted by increasing order. Finally returns a list of the first element of each tuple that sorted. def sort_tup(tup): #Code here input : tup1 = [(1, 15), (2, 8), (3, 22), (4, 30), (5, 15)] output: [4,3,1,5,2]
PYTHON PLS 1) Create a function search_by_pos. This function only has one return statement. This function...
PYTHON PLS 1) Create a function search_by_pos. This function only has one return statement. This function returns a set statement that finds out the same position and same or higher skill number. This function searches the dictionary and returns the same position and same or higher skill level. The function output the set statements that include the position only. For example input : dict = {'Fiora': {'Top': 1, 'Mid': 4, 'Bottom': 3},'Olaf': {'Top': 3, 'Mid': 2, 'Support': 4},'Yasuo': {'Mid': 2,...
python pls create a function party_place: that search the dictionary and figure out where they party...
python pls create a function party_place: that search the dictionary and figure out where they party in that day. For example def party_place(dict2: dict, date: (int,int,int)): dict1= {'fire1': {(2000,5,20,480) : ('Aaron', 25, 300, ( 0, 300)), (2000,5,20,720) : ('Baily', 45, 1500, (1500,500)), (2000,5,21,490) : ('Aaron', 35, 500, (1300,500)) }, 'fire2': {(2000,5,20,810) : ('Baily', 45, 1400, (600,1600)), (2000,5,20,930) : ('Baily', 43, 1800, ( 0, 0)) }} output print(party_place(dict1, (2000,5,20,720)) = ['fire1', 'fire2'] print(party_place(dict1, (2000,5,21,720)) = ['fire1'] print(party_place(dict1, (2000,5,22,720)) = []
Write a Python function that takes a list of integers as a parameter and returns the...
Write a Python function that takes a list of integers as a parameter and returns the sum of the elements in the list. Thank you.
Write a Python function that takes a list of integers as a parameter and returns the...
Write a Python function that takes a list of integers as a parameter and returns the sum of the elements in the list. Thank you.
python find min in the tuple of dictionaries by date also how to sort this tuple...
python find min in the tuple of dictionaries by date also how to sort this tuple by effectiveDate Requests = ( { "Id": 1, "itemId": 2, "amount": 50, "effectiveDate": "11/15/2015"}, { "Id": 2, "itemId": 1, "amount": 200, "effectiveDate": "11/20/2015"}, { "Id": 3, "itemId": 3, "amount": 5000, "effectiveDate": "10/5/2015"}, { "Id": 4, "itemId": 3, "amount": 600, "effectiveDate": "10/6/2015"} )
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT