Advertisement
PowerCell46

Fruit shop Python

Dec 15th, 2022 (edited)
1,242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.35 KB | None | 0 0
  1. fruit = str(input())
  2. day_of_the_week = str(input())
  3. quantity = float(input())
  4. price = 0
  5. there_is_an_error = False
  6.  
  7. if day_of_the_week == "Monday" or day_of_the_week == "Tuesday" or day_of_the_week == "Wednesday" or day_of_the_week == "Thursday" or day_of_the_week == "Friday":
  8.  
  9.     if fruit == "banana":
  10.         price = 2.50
  11.     elif fruit == "apple":
  12.         price = 1.20
  13.     elif fruit == "orange":
  14.         price = 0.85
  15.     elif fruit == "grapefruit":
  16.         price = 1.45
  17.     elif fruit == "kiwi":
  18.         price = 2.70
  19.     elif fruit == "pineapple":
  20.         price = 5.50
  21.     elif fruit == "grapes":
  22.         price = 3.85
  23.     else:
  24.         print("error")
  25.         there_is_an_error = True
  26.  
  27. elif day_of_the_week == "Saturday" or day_of_the_week == "Sunday":
  28.  
  29.     if fruit == "banana":
  30.         price = 2.70
  31.     elif fruit == "apple":
  32.         price = 1.25
  33.     elif fruit == "orange":
  34.         price = 0.90
  35.     elif fruit == "grapefruit":
  36.         price = 1.60
  37.     elif fruit == "kiwi":
  38.         price = 3.00
  39.     elif fruit == "pineapple":
  40.         price = 5.60
  41.     elif fruit == "grapes":
  42.         price = 4.20
  43.     else:
  44.         print("error")
  45.         there_is_an_error = True
  46.  
  47. else:
  48.     there_is_an_error = True
  49.     print("error")
  50.  
  51. if there_is_an_error == False:
  52.     sum = price * quantity
  53.     print(f'{sum:.2f}')
  54. else:
  55.     print()
  56.  
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement