Advertisement
KNenov96

Untitled

Nov 11th, 2022
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.54 KB | None | 0 0
  1. def main():
  2.     discovered_plants = {}
  3.     number_of_information = int(input())
  4.     for receiving_info in range(number_of_information):
  5.         plant, rarity = input().split("<->")
  6.         discovered_plants[plant] = [rarity]
  7.  
  8.     commands = input()
  9.     while commands != "Exhibition":
  10.         current_command = commands.split(": ")[0]
  11.         name_plant = commands.split(": ")[1].split(" - ")[0]
  12.  
  13.         if name_plant not in discovered_plants:
  14.             print("error")
  15.         elif current_command == "Rate":
  16.             rate_plant = int(commands.split(": ")[1].split(" - ")[1])
  17.             discovered_plants[name_plant].append(rate_plant)
  18.         elif current_command == "Update":
  19.             rarity_plant = commands.split(": ")[1].split(" - ")[1]
  20.             discovered_plants[name_plant][0] = rarity_plant
  21.         elif current_command == "Reset":
  22.             discovered_plants[name_plant] = discovered_plants[name_plant][0]
  23.  
  24.         commands = input()
  25.  
  26.     print("Plants for the exhibition:")
  27.     for plants_for_exhibition in discovered_plants:
  28.         name_of_plant = plants_for_exhibition
  29.         rarity_of_plant = discovered_plants[plants_for_exhibition][0]
  30.         calculating_rating = 0
  31.         if len(discovered_plants[plants_for_exhibition]) > 1:
  32.             calculating_rating = sum(discovered_plants[plants_for_exhibition][1:]) / \
  33.                                  len(discovered_plants[plants_for_exhibition][1:])
  34.  
  35.         print(f"- {name_of_plant}; Rarity: {rarity_of_plant}; Rating: {calculating_rating:.2f}")
  36.  
  37.  
  38. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement