Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- number_of_plants = int(input())
- plants = {}
- for _ in range(number_of_plants):
- plant, rarity = input().split('<->')
- plants[plant] = {'rarity': int(rarity), 'rating': []}
- command = input()
- while not command == 'Exhibition':
- command = command.split(': ')
- if command[0] == 'Rate':
- plant, rating = command[1].split(' - ')
- if plant in plants:
- plants[plant]['rating'].append(int(rating))
- else:
- print('error')
- elif command[0] == 'Update':
- plant, rarity = command[1].split(' - ')
- if plant in plants:
- plants[plant]['rarity'] = int(rarity)
- else:
- print('error')
- elif command[0] == 'Reset':
- plant = command[1]
- if plant in plants:
- plants[plant]['rating'] = []
- else:
- print('error')
- command = input()
- for plant, value in plants.items():
- if not value['rating']:
- plants[plant]['rating'] = 0
- else:
- plants[plant]['rating'] = sum(plants[plant]['rating'])/len((plants[plant]['rating']))
- print('Plants for the exhibition:')
- for plant, value in sorted(plants.items(), key=lambda kvp: (-kvp[1]['rarity'], -kvp[1]['rating'])):
- print(f"- {plant}; Rarity: {value['rarity']}; Rating: {value['rating']:.2f}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement