simeonshopov

Trade comission with 2d lists

Sep 20th, 2019
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1. town = input().lower()
  2. sells = float(input())
  3.  
  4. towns = ["sofia", "varna", "plovdiv"]
  5. com = [[0.05, 0.045, 0.055], [0.07, 0.075, 0.08], [0.08, 0.1, 0.12], [0.12, 0.13, 0.145]]
  6. small = 0 <= sells <= 500
  7. normal = 500 < sells <= 1000
  8. big = 1000 < sells <= 10000
  9. ultra = sells > 10000
  10.  
  11.  
  12. if small:
  13.   if town == (towns[0]):
  14.     print(f"{(sells * (com[0][0])):.2f}")
  15.   elif town == (towns[1]):
  16.     print(f"{(sells * (com[0][1])):.2f}")
  17.   elif town == (towns[2]):
  18.     print(f"{(sells * (com[0][2])):.2f}")
  19.   else:
  20.     print("error")
  21. elif normal:
  22.   if town == (towns[0]):
  23.     print(f"{(sells * (com[1][0])):.2f}")
  24.   elif town == (towns[1]):
  25.     print(f"{(sells * (com[1][1])):.2f}")
  26.   elif town == (towns[2]):
  27.     print(f"{(sells * (com[1][2])):.2f}")
  28.   else:
  29.     print("error")
  30. elif big:
  31.   if town == (towns[0]):
  32.     print(f"{(sells * (com[2][0])):.2f}")
  33.   elif town == (towns[1]):
  34.     print(f"{(sells * (com[2][1])):.2f}")
  35.   elif town == (towns[2]):
  36.     print(f"{(sells * (com[2][2])):.2f}")
  37.   else:
  38.     print("error")
  39. elif ultra:
  40.   if town == (towns[0]):
  41.     print(f"{(sells * (com[3][0])):.2f}")
  42.   elif town == (towns[1]):
  43.     print(f"{(sells * (com[3][1])):.2f}")
  44.   elif town == (towns[2]):
  45.     print(f"{(sells * (com[3][2])):.2f}")
  46.   else:
  47.     print("error")
  48. else:
  49.   print("error")
Advertisement
Add Comment
Please, Sign In to add comment