Question

In: Computer Science

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 prompts the user for the name of the item AND the price of each item, and then simply displays whatever the user typed in on the screen nicely formatted.

Solutions

Expert Solution

Prorgam:

name_array = list()
price_array = list()
for x in range(8):
name = input("Enter item name: ")
name_array.append(str(name))
price = input("Enter item price: ")
price_array.append(float(price))

print(" List of items and their prices")
for i in range(8):
print("Name:",name_array[i])
print("Price:$",price_array[i])

Output:

Process:

First take two arrays , or we can say lists where one will store name of item and other will store price of item

Here we have taken name_array to store name of item and price_array to store price of item

Now as we know we have 8 items we will take a for loop which will run in range of 1 to 8

In each iteration it will ask for name of item and then store this to name_array by using append function, also to mention here we are using type as str to store name

Similarly it will take price and will store in price_array and to store this we are using type float.

Now to print the list we will use for loop and the print the values using index location traced by loop counter i.
  


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
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...
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...
Grocery List Program Write a program that keeps track of the user's grocery list items. Prompt...
Grocery List Program Write a program that keeps track of the user's grocery list items. Prompt the user if they'd like to (each action is a function): See the list Display all items (if any) in the list Add item to their list Confirm with the user before adding item (y/n or yes/no) If they enter a duplicate item, notify them the item already exists Remove items from their list Confirm with the user before removing item (y/n or yes/no)...
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...
Develop a python program that will determine if a department store customer has exceeded the credit...
Develop a python program that will determine if a department store customer has exceeded the credit limit on a charge account. For each customer, the following facts are available:  Account number  Balance at the beginning of the month  Total of all items charged by this customer this month  Total of all credits applied to this customer’s account this month  Allowed credit limit The program should input each of the facts, calculate the new balance (=beginning...
A customer in a store is purchasing two items. Design a program using module pseudocode that...
A customer in a store is purchasing two items. Design a program using module pseudocode that asks for the price of each item in dollars, and then displays three things in their output receipt - the subtotal of the sale in dollars, the amount of sales tax in dollars and the final amount paid by the customer in dollars. Assume the sales tax is 4 percent.
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.
Here are some prices for randomly selected grocery items from the grocery store: Items Prices: Cheese...
Here are some prices for randomly selected grocery items from the grocery store: Items Prices: Cheese $3.29 Butter $4.99 Eggs $3.49 Yogurt $3.49 Juice $3.89 Tea $3.69 Chips $3.99 Soda $1.99 Pastry $2.99 Cerrial $4.99 Oats $3.29 Almond Milk $2.79 Almonds $4.39 Popcorn $3.29 Crackers $3.59 Ice Cream $6.99 Cookies $2.99 Jam $3.69 Peanut Butter $3.29 Coffee $3.19 Green Tea $4.99 BBQ Sauce $2.99 Oil $6.69 Mayonnaise $4.59 Mustard $2.99 1. Compute the sample mean x and the sample standard...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT