SlideShare ist ein Scribd-Unternehmen logo
1 von 1
please help me with this. for example
shopping list = [banana, orange, apple]
stock={banana:6,apple:0,Orange:32,pear:15}
prices={banana:4, apple:2, orange:1.5, pear: 3}
also it should print the remainder in the stock eg if banana is picked it remains 5 and so on.
thanks in advance
write a program thet goes through the shopping ist and chacks the item is in the stock If it is then
it ceduces the stock adds the unit price to the total. Finaly it prints the total and the stock
Solution
shopping_list = ["banana", "orange", "apple", "apple", "apple", "apple", "apple",
"apple"] stock = { "banana": 6, "apple": 0, "orange": 32, "pear": 15 } prices = {
"banana": 4, "apple": 2, "orange": 1.5, "pear": 3 } def compute_bill(food): total = 0 for item
in food: total += prices[item] return total print compute_bill(shopping_list)

Weitere ähnliche Inhalte

Mehr von ceveline2

Please explain how HDFS provides redundancy for stored dataSolutionHDF.docx
Please explain how HDFS provides redundancy for stored dataSolutionHDF.docxPlease explain how HDFS provides redundancy for stored dataSolutionHDF.docx
Please explain how HDFS provides redundancy for stored dataSolutionHDF.docxceveline2
 
Please describe cash flows from investing activities- and provide thre.docx
Please describe cash flows from investing activities- and provide thre.docxPlease describe cash flows from investing activities- and provide thre.docx
Please describe cash flows from investing activities- and provide thre.docxceveline2
 
Please clear hand written for the answersSolution15- (c) An increase i.docx
Please clear hand written for the answersSolution15- (c) An increase i.docxPlease clear hand written for the answersSolution15- (c) An increase i.docx
Please clear hand written for the answersSolution15- (c) An increase i.docxceveline2
 
please answer the following- thanks!!! Question 3 (1 point) 6 Rutherfo.docx
please answer the following- thanks!!! Question 3 (1 point) 6 Rutherfo.docxplease answer the following- thanks!!! Question 3 (1 point) 6 Rutherfo.docx
please answer the following- thanks!!! Question 3 (1 point) 6 Rutherfo.docxceveline2
 
Please answer questions 1-4- thank you!Solution1- Acids are the conpou.docx
Please answer questions 1-4- thank you!Solution1- Acids are the conpou.docxPlease answer questions 1-4- thank you!Solution1- Acids are the conpou.docx
Please answer questions 1-4- thank you!Solution1- Acids are the conpou.docxceveline2
 
Please answer in a clear manner to get the points- Thanks for the help.docx
Please answer in a clear manner to get the points- Thanks for the help.docxPlease answer in a clear manner to get the points- Thanks for the help.docx
Please answer in a clear manner to get the points- Thanks for the help.docxceveline2
 
Please answer bothSolution18- Nature chose polyamides to form proteins.docx
Please answer bothSolution18- Nature chose polyamides to form proteins.docxPlease answer bothSolution18- Nature chose polyamides to form proteins.docx
Please answer bothSolution18- Nature chose polyamides to form proteins.docxceveline2
 
Phe following GC data was obtained on a Polar column- The 10 possible.docx
Phe following GC data was obtained on a Polar column- The 10 possible.docxPhe following GC data was obtained on a Polar column- The 10 possible.docx
Phe following GC data was obtained on a Polar column- The 10 possible.docxceveline2
 
Patients in shock experience decreased delivery of O2 to tissues- decr.docx
Patients in shock experience decreased delivery of O2 to tissues- decr.docxPatients in shock experience decreased delivery of O2 to tissues- decr.docx
Patients in shock experience decreased delivery of O2 to tissues- decr.docxceveline2
 
Perform an analysis of the social - demographic- technological- econom.docx
Perform an analysis of the social - demographic- technological- econom.docxPerform an analysis of the social - demographic- technological- econom.docx
Perform an analysis of the social - demographic- technological- econom.docxceveline2
 

Mehr von ceveline2 (10)

Please explain how HDFS provides redundancy for stored dataSolutionHDF.docx
Please explain how HDFS provides redundancy for stored dataSolutionHDF.docxPlease explain how HDFS provides redundancy for stored dataSolutionHDF.docx
Please explain how HDFS provides redundancy for stored dataSolutionHDF.docx
 
Please describe cash flows from investing activities- and provide thre.docx
Please describe cash flows from investing activities- and provide thre.docxPlease describe cash flows from investing activities- and provide thre.docx
Please describe cash flows from investing activities- and provide thre.docx
 
Please clear hand written for the answersSolution15- (c) An increase i.docx
Please clear hand written for the answersSolution15- (c) An increase i.docxPlease clear hand written for the answersSolution15- (c) An increase i.docx
Please clear hand written for the answersSolution15- (c) An increase i.docx
 
please answer the following- thanks!!! Question 3 (1 point) 6 Rutherfo.docx
please answer the following- thanks!!! Question 3 (1 point) 6 Rutherfo.docxplease answer the following- thanks!!! Question 3 (1 point) 6 Rutherfo.docx
please answer the following- thanks!!! Question 3 (1 point) 6 Rutherfo.docx
 
Please answer questions 1-4- thank you!Solution1- Acids are the conpou.docx
Please answer questions 1-4- thank you!Solution1- Acids are the conpou.docxPlease answer questions 1-4- thank you!Solution1- Acids are the conpou.docx
Please answer questions 1-4- thank you!Solution1- Acids are the conpou.docx
 
Please answer in a clear manner to get the points- Thanks for the help.docx
Please answer in a clear manner to get the points- Thanks for the help.docxPlease answer in a clear manner to get the points- Thanks for the help.docx
Please answer in a clear manner to get the points- Thanks for the help.docx
 
Please answer bothSolution18- Nature chose polyamides to form proteins.docx
Please answer bothSolution18- Nature chose polyamides to form proteins.docxPlease answer bothSolution18- Nature chose polyamides to form proteins.docx
Please answer bothSolution18- Nature chose polyamides to form proteins.docx
 
Phe following GC data was obtained on a Polar column- The 10 possible.docx
Phe following GC data was obtained on a Polar column- The 10 possible.docxPhe following GC data was obtained on a Polar column- The 10 possible.docx
Phe following GC data was obtained on a Polar column- The 10 possible.docx
 
Patients in shock experience decreased delivery of O2 to tissues- decr.docx
Patients in shock experience decreased delivery of O2 to tissues- decr.docxPatients in shock experience decreased delivery of O2 to tissues- decr.docx
Patients in shock experience decreased delivery of O2 to tissues- decr.docx
 
Perform an analysis of the social - demographic- technological- econom.docx
Perform an analysis of the social - demographic- technological- econom.docxPerform an analysis of the social - demographic- technological- econom.docx
Perform an analysis of the social - demographic- technological- econom.docx
 

Kürzlich hochgeladen

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 

Kürzlich hochgeladen (20)

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 

Python program to calculate shopping bill from list and stock

  • 1. please help me with this. for example shopping list = [banana, orange, apple] stock={banana:6,apple:0,Orange:32,pear:15} prices={banana:4, apple:2, orange:1.5, pear: 3} also it should print the remainder in the stock eg if banana is picked it remains 5 and so on. thanks in advance write a program thet goes through the shopping ist and chacks the item is in the stock If it is then it ceduces the stock adds the unit price to the total. Finaly it prints the total and the stock Solution shopping_list = ["banana", "orange", "apple", "apple", "apple", "apple", "apple", "apple"] stock = { "banana": 6, "apple": 0, "orange": 32, "pear": 15 } prices = { "banana": 4, "apple": 2, "orange": 1.5, "pear": 3 } def compute_bill(food): total = 0 for item in food: total += prices[item] return total print compute_bill(shopping_list)