Spocoman

07. Trekking Mania

Dec 25th, 2021 (edited)
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.44 KB | None | 0 0
  1. group_numbers = int(input())
  2. musala = 0
  3. montBlanc = 0
  4. kilimanjaro = 0
  5. k2 = 0
  6. everest = 0
  7. alpinist_sum = 0
  8.  
  9. for i in range(group_numbers):
  10.     group_num = int(input())
  11.     alpinist_sum += group_num
  12.  
  13.     if group_num > 40:
  14.         everest += group_num
  15.     elif group_num > 25:
  16.         k2 += group_num
  17.     elif group_num > 12:
  18.         kilimanjaro += group_num
  19.     elif group_num > 5:
  20.         montBlanc += group_num
  21.     elif group_num > 0:
  22.         musala += group_num
  23.  
  24. print(f'{musala / alpinist_sum * 100:.2f}%')             #Или: for mountain in (musala, montBlanc, kilimanjaro, k2, everest):
  25. print(f'{montBlanc / alpinist_sum * 100:.2f}%')          #         print(f'{mountain / alpinist_sum * 100:.2f}%')
  26. print(f'{kilimanjaro / alpinist_sum * 100:.2f}%')
  27. print(f'{k2 / alpinist_sum * 100:.2f}%')
  28. print(f'{everest / alpinist_sum * 100:.2f}%')
  29.  
  30.  
  31. Фундаменталс решение:
  32.  
  33. mountains = {'musala': 0, 'montBlanc': 0, 'kilimanjaro': 0, 'k2': 0, 'everest': 0}
  34. group_numbers = int(input())
  35.  
  36. for i in range(group_numbers):
  37.     group_num = int(input())
  38.     destination = {group_num > 0: 'musala',
  39.                    group_num > 5: 'montBlanc',
  40.                    group_num > 12: 'kilimanjaro',
  41.                    group_num > 25: 'k2',
  42.                    group_num > 40: 'everest'}
  43.  
  44.     mountains[destination[True]] += group_num
  45.  
  46. for mountain in mountains.values():
  47.     print(f'{mountain / sum(mountains.values()) * 100:.2f}%')
  48.  
Add Comment
Please, Sign In to add comment