Question

In: Computer Science

Python: Write a program to simulate the purchases in a grocery store. A customer may buy...

Python: Write a program to simulate the purchases in a grocery store. A customer may buy any number of items. So, you should use a while loop. Your program should read an item first and then read the price until you enter a terminal value (‘done’) to end the loop. You should add all the prices inside the loop. Add then a sales tax of 8.75% to the total price. Print a receipt to indicate all the details of the purchase. All numbers must be appropriately formatted. For example, when the program starts, it shall prompt user to enter line item, say “enter an item or end the program by entering ‘done’ >> “. After user enters the item, say “book”, the program shall prompt user enter price, say “please enter the price you pay, without dollar sign, just a number >> ‘. Then the program repeats the process until user prompts ‘done’. Students may get partial credits if they draw problem solving strategy and pseudo-code when they could not get their program run successfully. When the program run successfully, there is no need to do that.

Solutions

Expert Solution

(Below is the code in python which takes items and then its price and displays the receipt:) ---

str=input("enter an item or end the program by entering 'done' >> ")

book_list=[]
price_list=[]
total=0
while str!='done':
    book_list.append(str)
    price=float(input("please enter the price you pay, without dollar sign, just a number >> "))
    price_list.append(price)
    total +=price;
    str=input("enter an item or end the program by entering 'done' >> ")
    
print("\nReceipt:")
for i in range(0,len(book_list)):
    print(i+1,". ",book_list[i],"     ",price_list[i])

total_price=(108.75/100)*total
print("\nSales Tax:   ",((8.75/100)*total))
print("\nTotal price: ",total_price)

Output sample -1:

Code image :


Related Solutions

A customer comes into a grocery store and buys 8 items. Write a PYTHON program that...
A customer comes into a grocery store and buys 8 items. Write a PYTHON program that asks for the name of the item and the price of each item, and then displays these on the screen. Refer to the print() and input() statements covered in the module. Do NOT use loops as it will be covered in later modules. Apples 2.10 Hamburger 3.25 Milk 3.49 Sugar 1.99 Bread 1.76 Deli Turkey 7.99 Pickles 3.42 Butter 2.79
Dean goes to the grocery store to buy chips and soda for a party. He purchases...
Dean goes to the grocery store to buy chips and soda for a party. He purchases brand name products even though generic versions are available at lower prices. His friend John says he was irrational to spend more for a nearly identical product. His friend Martina agreed with Dean’s decision to spend more for the brand name products. a. Refer to Scenario 4. Which friend is a critic of brand names? b. Refer to Scenario 4. Martina offers two reasons...
A grocery store receipts show that Sunday customer purchases have a skewed distribution with a mean...
A grocery store receipts show that Sunday customer purchases have a skewed distribution with a mean of $35 and a standard deviation of $23. Suppose the store had 324 customers this Sunday A) Estimate the probability that the store's revenues were at least $12,200? B) If, on a typical Sunday, the store serves 324 customers, how much does the store take in on the worst 10% of such days?
A customer in a grocery store is purchasing three items. Write the pseudo code that will:...
A customer in a grocery store is purchasing three items. Write the pseudo code that will: • Ask the user to enter the name of the first item purchased. Then ask the user to enter the cost of the first item purchased. Make your program user friendly. If the user says the first item purchased is milk, then ask: “What is the cost of milk.” [This should work no matter what item is entered by the user. I might buy...
Write a program in Python to simulate a Craps game: 1. When you bet on the...
Write a program in Python to simulate a Craps game: 1. When you bet on the Pass Line, you win (double your money) if the FIRST roll (a pair of dice) is a 7 or 11, you lose if it is ”craps” (2, 3, or 12). Otherwise, if it is x ∈ {4, 5, 6, 8, 9, 10}, then your point x is established, and you win when that number is rolled again before ’7’ comes up. The game is...
Create a Python 3 program that acts as a grocery store shopping cart. 1. Create a...
Create a Python 3 program that acts as a grocery store shopping cart. 1. Create a class named GroceryItem. This class should contain: - an __init__ method that initializes the item’s name and price - a get_name method that returns the item’s name - a get_price method that returns the item’s price - a __str__ method that returns a string representation of that GroceryItem - an unimplemented method is_perishable Save this class in GroceryItem.py. 2. Create a subclass Perishable that...
IN PYTHON: Write a program to study countries and their capitals. The program will store country:capital...
IN PYTHON: Write a program to study countries and their capitals. The program will store country:capital information and allow the user to quiz themselves. These two functions are required for this assignment. You may add other functions that you deem appropriate: - menu()   This function, which displays all the user options to the screen, prompts the user for their choice and returns their choice. This function will verify user input and ALWAYS return a valid choice. - addCapital(dict) This function...
Calculate your Customer Lifetime Value (CLTV) as a grocery customer. How should a grocery store segment...
Calculate your Customer Lifetime Value (CLTV) as a grocery customer. How should a grocery store segment its market? Why? Create personas for each market segment the store should have.
Write a program in python programming language to implement/simulate a finite automaton that accepts (only): odd...
Write a program in python programming language to implement/simulate a finite automaton that accepts (only): odd Binary numbers // 00000000, 0101, 111111, etc. Show: Finite Automaton Definition, Graph, Table
Write a program in python programming language to implement/simulate a finite automaton that accepts (only): unsigned...
Write a program in python programming language to implement/simulate a finite automaton that accepts (only): unsigned integer numbers // 123, 007, 4567890, etc. Show: Finite Automaton Definition, Graph, Table.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT