In: Computer Science
Exercise 5: Day Old Bread A bakery sells loaves of bread for £1.49 each. Day old bread is discounted by 60 percent. Write a program that begins by reading the number of loaves of day old bread being purchased from the user. Then your program should display the regular price for the bread, the discount because it is a day old, and the total price. All of the values should be displayed using two decimal places, and the decimal points in all of the numbers should be aligned when reasonable values are entered by the user.
used : python
Python code:
#accepting the quantity
num=int(input("Enter the number of loaves of day old bread you wish
to purchase: "))
#printing Regular price
print("Regular price: {:<5}£{:.2f}".format(' ',1.49*num))
#printing Discount
print("Discount: {:<11}£{:.2f}".format(' ',1.49*num*.6))
#printing Total price
print("Total price: {:<8}£{:.2f}".format('
',1.49*num-1.49*num*.6))
Screenshot:
Input and Output: