Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Posted it before but I didn't post the code as text, so I'm posted again. Have a great day! python!!! I am a little confused

Posted it before but I didn't post the code as text, so I'm posted again. Have a great day!

python!!! I am a little confused about how to code this, If someone could help me that would be great. Thank you!

image text in transcribedimage text in transcribed

----------------------------------------------------------------------------------------------------------------------image text in transcribed

from collections import namedtuple #POS termial program

#item is a named tuple containing all the data for an item that the store carries. #code is an integer, description is a string, price is a float, and taxable is a Boolean item = namedtuple('code',['description','price','taxable'])

#purchase is a named tuple containing all the data for an item that a customer has purchsed. #code is an integer, description is a string, price is a float, and taxable is a Boolean purchase = namedtuple('purchase',['code','quantity','item_total','item_tax'])

##Create a catalog of the prices of the items (stored representation)

catalog = {11:item("orange",0.45,False), 25:item("wrench",8.97,True), 34:item("peach",0.56,False), 8:item("blueberries",3.09,False), 17:item("peanuts",1.99,False), 4:item("milk",2.75,False), 120:item("avocado",0.65,False), 6:item("whole coffee",5.85,False), 99:item("shampoo",4.05,True), 12:item("toothbrush",0.56,True), 45:item("chicken",4.47,False), 196:item("eggs",1.35,False), 197:item("brown eggs",2.65,False), 26:item("brie",3.85,False), 96:item("almond milk",1.99,False), 526:item("cilantro",0.85,False), 52:item("carrots",1.35,False), 116:item("broccoli",1.65,False), 128:item("garlic",1.09,False), 134:item("kale",3.55,False), 46:item("zucchini",1.45,False), 216:item("face mask",3.99,False), 226:item("smoke alarm",14.99,False)}

##For each item item = input("Enter the first code, 0 to quit") while item != 0: item_code = int(item) #get and calculate rest of stuff #create a named tuple for the data for this item and add it to the list item = input("enter another code, 0 to quit")

## ask for item code ## ask for item quantity ## calculate item total (price*quantity) ## Is the item taxable? ## Calculate the tax ## place all the values for this item into a tuple and add to the order list

##for each item, the new structure stores - code, quantity, item_total, item_tax

order = [purchase(11,3,1.35,0.0), purchase(34,1,0.56,0.0), purchase(111,4,1.80,0.0), purchase(25,2,17.94,1.56)] #sample order for discussion of the assignment - in the program, this will be built by the input and calculation section ##For each item ## Print a detail line of the receipt with description, count, unit price, and total price ## if tax is not 0 ## print tax line ##Calculate total ##Print labeled total

the tax is 0.07 also if you zoom in the text wont be blurry. also the code is put into text form
The attached algorithm and data structures revised.py file contains a starting algorithm and data structures for the Point-of-Sale (POS) terminal program that we have been discussion. The catalogText.py program contains the definitions for the named tuples that will hold the information about each item the store has in stock and the information about each item that the customer has in their order. It also contains the catalog of all the items in the store's inventory. You MUST use the named tuples and the catalog in your program. You need to complete the program. The finished progam will allow the user (a cashier) to enter any sequence of purchases (code and quantity for each item purchased) and then print a formatted receipt like this: 4 @ 1 @ 0.45 11.69 Orange Wrench Tax Blueberries Total $ $ $ $ 1.80 11.69 0.81 5.00 2 @ 2.50 $ 21.30 Correct formatting of the receipt is an important part of the grade for this assignment. Note that the money columns have the decimal points lined up. Your program must do the same. You can assume that all of the money amounts will have no more than 4 digits to the left of the decimal point. Note also that the item descriptions are right- justified (aligned to the right of the field), which your program must also do. You can assume that descriptions are no more than 15 characters long. NOTE: The cashier enters 0 to quit data entry. When your program is finished, upload the .py file to this assignment link. File Edit Format Run Options Window Help from collections import namedtuple #POS termial program #item is a named tuple containing all the data for an item that the store carries. #code is an integer, description is a string, price is a float, and taxable is a Boolean item = namedtuple('code', ['description', 'price', 'taxable']) #purchase is a named tuple containing all the data for an item that a customer has purchsed. #code is an integer, description is a string, price is a float, and taxable is a Boolean purchase = namedtuple ('purchase', ['code', 'quantity','item_total', 'item_tax']) ##Create a catalog of the prices of the items (stored representation) catalog = {11: item("orange",0.45, False), 25:item ("wrench", 8.97, True), 34:item ("peach", 0.56, False), 8:item("blueberries", 3.09, False), 17:item ("peanuts", 1.99, False), 4:item ("milk",2.75, False), 120:item("avocado",0.65, False), 6:item ("whole coffee",5.85, False), 99:item ("shampoo", 4.05, True), 12:item("toothbrush",0.56, True), 45:item("chicken", 4.47, False), 196:item("eggs", 1.35, False), 197:item("brown eggs", 2.65, False), 26:item ("brie", 3.85, False), 96: item("almond milk",1.99, False), 526: item("cilantro",0.85, False), 52:item("carrots", 1.35, False), 116:item ("broccoli", 1.65, False), 128:item("garlic", 1.09, False), 134:item("kale", 3.55, False), 46:item ("zucchini",1.45, False), 216: item("face mask", 3.99, False), 226: item("smoke alarm", 14.99, False) } # #For each item item = input ("Enter the first code, 0 to quit") while item != 0: item_code = int(item) #get and calculate rest of stuff #create a named tuple for the data for this item and add it to the list item = input("enter another code, 0 to quit") ## ask for item code ## For each item item = input ("Enter the first code, 0 to quit") while item != 0: item_code = int(item) #get and calculate rest of stuff #create a named tuple for the data for this item and add it to the list item = input ("enter another code, 0 to quit") ## ## ask for item code ask for item quantity calculate item total (price* quantity) Is the item taxable? Calculate the tax place all the values for this item into a tuple and add to the order list ## ## ##for each item, the new structure stores - code, quantity, item_total, item_tax order = [purchase (11,3,1.35,0.0), purchase (34,1,0.56,0.0), purchase (111,4,1.80,0.0), purchase (25,2,17.94,1.56)] #sample order for discussion of the assignment - in the program, this will be built by the input and calculation section ## For each item ## Print a detail line of the receipt with description, count, unit price, and total price ## if tax is not 0 ## print tax line ##Calculate total ##Print labeled total The attached algorithm and data structures revised.py file contains a starting algorithm and data structures for the Point-of-Sale (POS) terminal program that we have been discussion. The catalogText.py program contains the definitions for the named tuples that will hold the information about each item the store has in stock and the information about each item that the customer has in their order. It also contains the catalog of all the items in the store's inventory. You MUST use the named tuples and the catalog in your program. You need to complete the program. The finished progam will allow the user (a cashier) to enter any sequence of purchases (code and quantity for each item purchased) and then print a formatted receipt like this: 4 @ 1 @ 0.45 11.69 Orange Wrench Tax Blueberries Total $ $ $ $ 1.80 11.69 0.81 5.00 2 @ 2.50 $ 21.30 Correct formatting of the receipt is an important part of the grade for this assignment. Note that the money columns have the decimal points lined up. Your program must do the same. You can assume that all of the money amounts will have no more than 4 digits to the left of the decimal point. Note also that the item descriptions are right- justified (aligned to the right of the field), which your program must also do. You can assume that descriptions are no more than 15 characters long. NOTE: The cashier enters 0 to quit data entry. When your program is finished, upload the .py file to this assignment link. File Edit Format Run Options Window Help from collections import namedtuple #POS termial program #item is a named tuple containing all the data for an item that the store carries. #code is an integer, description is a string, price is a float, and taxable is a Boolean item = namedtuple('code', ['description', 'price', 'taxable']) #purchase is a named tuple containing all the data for an item that a customer has purchsed. #code is an integer, description is a string, price is a float, and taxable is a Boolean purchase = namedtuple ('purchase', ['code', 'quantity','item_total', 'item_tax']) ##Create a catalog of the prices of the items (stored representation) catalog = {11: item("orange",0.45, False), 25:item ("wrench", 8.97, True), 34:item ("peach", 0.56, False), 8:item("blueberries", 3.09, False), 17:item ("peanuts", 1.99, False), 4:item ("milk",2.75, False), 120:item("avocado",0.65, False), 6:item ("whole coffee",5.85, False), 99:item ("shampoo", 4.05, True), 12:item("toothbrush",0.56, True), 45:item("chicken", 4.47, False), 196:item("eggs", 1.35, False), 197:item("brown eggs", 2.65, False), 26:item ("brie", 3.85, False), 96: item("almond milk",1.99, False), 526: item("cilantro",0.85, False), 52:item("carrots", 1.35, False), 116:item ("broccoli", 1.65, False), 128:item("garlic", 1.09, False), 134:item("kale", 3.55, False), 46:item ("zucchini",1.45, False), 216: item("face mask", 3.99, False), 226: item("smoke alarm", 14.99, False) } # #For each item item = input ("Enter the first code, 0 to quit") while item != 0: item_code = int(item) #get and calculate rest of stuff #create a named tuple for the data for this item and add it to the list item = input("enter another code, 0 to quit") ## ask for item code ## For each item item = input ("Enter the first code, 0 to quit") while item != 0: item_code = int(item) #get and calculate rest of stuff #create a named tuple for the data for this item and add it to the list item = input ("enter another code, 0 to quit") ## ## ask for item code ask for item quantity calculate item total (price* quantity) Is the item taxable? Calculate the tax place all the values for this item into a tuple and add to the order list ## ## ##for each item, the new structure stores - code, quantity, item_total, item_tax order = [purchase (11,3,1.35,0.0), purchase (34,1,0.56,0.0), purchase (111,4,1.80,0.0), purchase (25,2,17.94,1.56)] #sample order for discussion of the assignment - in the program, this will be built by the input and calculation section ## For each item ## Print a detail line of the receipt with description, count, unit price, and total price ## if tax is not 0 ## print tax line ##Calculate total ##Print labeled total

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data 29th British National Conference On Databases Bncod 2013 Oxford Uk July 2013 Proceedings Lncs 7968

Authors: Dan Olteanu ,Georg Gottlob ,Christian Schallhart

2013th Edition

3642394663, 978-3642394669

More Books

Students also viewed these Databases questions