tod36

9.2.1. Passion days https://python-book.softuni.bg/cha

Apr 26th, 2020
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. enter_sum = float(input())
  2. all_shopping_sum = 0
  3. all_shopping_pieces = 0
  4. price_of_item = 0
  5. command = input()
  6.  
  7. while command != 'mall.Enter':
  8.     command = input()
  9. command = input()
  10. while command != 'mall.Exit':
  11.     all_shopping_pieces += 1
  12.     for i in range(len(command)):
  13.         b = ord(command[i])
  14.         if 65 <= b <= 90:
  15.             price_of_item = b * 0.5
  16.         elif 97 <= b <= 122:
  17.             price_of_item = 0.3 * b
  18.         elif command[i] == '%':
  19.             price_of_item = 0.5 * (enter_sum - all_shopping_sum)
  20.         elif command[i] == '*':
  21.             price_of_item = -10
  22.         all_shopping_sum += price_of_item
  23.         if all_shopping_sum > enter_sum:
  24.             all_shopping_sum -= price_of_item
  25.             all_shopping_pieces -= 1
  26.         price_of_item = 0
  27.         i += 1
  28.     command = input()
  29. if all_shopping_pieces <= 0:
  30.     print(f'No purchases. Money left: {(enter_sum-all_shopping_sum):.2f} lv.')
  31. else:
  32.     print(f'{all_shopping_pieces} purchases. Money left: {(enter_sum-all_shopping_sum):.2f} lv.')
Add Comment
Please, Sign In to add comment