Answer to Question #113916 in Python for James

Question #113916
Secondhand Rose Resale Shop is having a seven-day sale during which the price of any unsold item drops 10 percent each day. For example, an item that costs $10.00 on the first day costs 10 percent less, or 9.00, on the second day. On the third day, the same item is 10 percent less than $9.00, or $8.10. Design an application that allows a user to input a price until an appropriate sentinel value is entered. Output is the price of each item on each day, one through seven.
1
Expert's answer
2020-05-05T03:47:49-0400
# ask user to enter item price
# until sentinel value is entered (less or equal zero)
while True:
  price = input('Enter item price: ')
  price = float(price)

  # if price less or equal 0 - exit loop
  if price <= 0:
    break

  # compute prices with discount for seven days 
  discount_price = price
  for day in range(1, 8):
    print(' day {0}, price: ${1:.2f}'.format(day, discount_price))
    discount_price *= 0.9;

  print() # empty line

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS