Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### работещ код 100/100
- number_of_information = int(input())
- my_plants = {}
- for receiving in range(number_of_information):
- information_for_plants = input().split("<->")
- plant_name = information_for_plants[0]
- rarity = information_for_plants[1]
- my_plants[plant_name] = [rarity, []]
- exhibition = False
- while not exhibition:
- commands = input()
- if commands == "Exhibition":
- exhibition = True
- break
- commands = commands.split(": ")
- current_command = commands[0]
- if current_command == "Rate":
- plant_for_rate = commands[1].split(" - ")[0]
- rating = int(commands[1].split(" - ")[1])
- if plant_for_rate in my_plants:
- my_plants[plant_for_rate][1].append(rating)
- else:
- print("error")
- elif current_command == "Update":
- plant_for_update = commands[1].split(" - ")[0]
- plant_rarity = commands[1].split(" - ")[1]
- if plant_for_update in my_plants:
- my_plants[plant_for_update][0] = plant_rarity
- else:
- print("error")
- elif current_command == "Reset":
- plant_for_reset = commands[1]
- if plant_for_reset in my_plants:
- my_plants[plant_for_reset][1] = []
- else:
- print("error")
- print("Plants for the exhibition:")
- for plant in my_plants:
- if len(my_plants[plant][1]) > 0:
- rating_current_plant = sum(my_plants[plant][1]) / len(my_plants[plant][1])
- else:
- rating_current_plant = 0
- print(f"- {plant}; Rarity: {my_plants[plant][0]}; Rating: {rating_current_plant:.2f}")
- ##### не работещ код 87/100 рънтайм
- def main():
- discovered_plants = {}
- number_of_information = int(input())
- for receiving_info in range(number_of_information):
- plant, rarity = input().split("<->")
- discovered_plants[plant] = [rarity]
- commands = input()
- while commands != "Exhibition":
- current_command = commands.split(": ")[0]
- name_plant = commands.split(": ")[1].split(" - ")[0]
- if name_plant not in discovered_plants:
- print("error")
- elif current_command == "Rate":
- rate_plant = int(commands.split(": ")[1].split(" - ")[1])
- discovered_plants[name_plant].append(rate_plant)
- elif current_command == "Update":
- rarity_plant = commands.split(": ")[1].split(" - ")[1]
- discovered_plants[name_plant][0] = rarity_plant
- elif current_command == "Reset":
- discovered_plants[name_plant] = discovered_plants[name_plant][0]
- commands = input()
- print("Plants for the exhibition:")
- for plants_for_exhibition in discovered_plants:
- name_of_plant = plants_for_exhibition
- rarity_of_plant = discovered_plants[plants_for_exhibition][0]
- calculating_rating = 0
- if len(discovered_plants[plants_for_exhibition]) > 1:
- calculating_rating = sum(discovered_plants[plants_for_exhibition][1:]) / \
- len(discovered_plants[plants_for_exhibition][1:])
- print(f"- {name_of_plant}; Rarity: {rarity_of_plant}; Rating: {calculating_rating:.2f}")
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement