Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- num = int(input())
- flowers_dict = {}
- for i in range(num):
- data = input().split("<->")
- plant = data[0]
- rarity = int(data[1])
- if plant not in flowers_dict:
- flowers_dict[plant] = [rarity]
- stat = input().split(": ")
- while True:
- command = stat[0]
- if command == "Exhibition":
- break
- if command == "Rate":
- rating_data = stat[1].split(" - ")
- flower = rating_data[0]
- rating = int(rating_data[1])
- if flower in flowers_dict:
- flowers_dict[flower].append(rating)
- else:
- print("error")
- elif command == "Update":
- rarity_data = stat[1].split(" - ")
- current_flower = rarity_data[0]
- new_rarity = int(rarity_data[1])
- if current_flower in flowers_dict:
- flowers_dict[current_flower][0] = new_rarity
- else:
- print("error")
- elif command == "Reset":
- reset_flower = stat[1]
- if reset_flower in flowers_dict:
- for i in range(1, len(flowers_dict[reset_flower])):
- flowers_dict[reset_flower].pop(1)
- else:
- print("error")
- stat = input().split(": ")
- average_stat = {}
- for i in flowers_dict:
- if len(flowers_dict[i]) == 1:
- average = 0
- else:
- average = (sum(flowers_dict[i]) - flowers_dict[i][0]) / (len(flowers_dict[i]) - 1)
- average_stat[i] = average
- print("Plants for the exhibition:")
- result = {}
- for i in flowers_dict:
- result[i] = [flowers_dict[i][0], average_stat[i]]
- sorted_list = []
- for i in result:
- sorted_list.append(result[i][0])
- sorted_list.sort()
- sorted_list.reverse()
- for x in sorted_list:
- for y in result:
- if x == result[y][0]:
- print(f"- {y}; Rarity: {result[y][0]}; Rating: {result[y][1]:.2f}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement