Assume, you have been given a string that contains a few products name, prices, and, costing respectively, and an integer value as a budget for shopping. Now, write a python program that will calculate the total costing of products from the given string and check whether it is possible to buy those products while being within the budget. If the total costing is greater than the budget, then print "Shopping not possible". Otherwise, print "Yay!! Shopping possible". If the quantity of any of the products is less than 1, then print "Quantity must be greater than 0". Given 1: data = "Apples,5,2,0ranges,10,1,Eggs,3,5" budget= 70 Sample Output 1: Costing in dictionary: {'Apples': 10, 'Oranges': 10, 'Eggs': 15} Total costing: 35 Total Budget: 70 Yay!! Shopping possible Explanation 1: The 1st product is Apples, and each apple costs 5 takas and 2 is the buying quantity of apples. So, the cost of apples is 5*2=10 taka. The 2nd product is Oranges, and each orange costs 10 takas, and 1 is the buying quantity of oranges. So, the cost of Orange is 10*1=10 taka. The 3rd product is Eggs, and each egg costs 3 takas and 5 is the buying quantity of eggs. So, the cost of eggs is 3*5=15 taka. So, total costing= 10+10+15=35 taka which is less than the budget of 70. So, You can buy these items. Given 2: data = "Apples,5,2,0ranges,10,0,Eggs,3,5" budget= 70 Sample Output 2: Quantity must be greater than 0 Explanation 2: Here Oranges buying quantity is 0. According to the given condition, costing calculation is not possible. Given3: data = "Apples,5,2,0ranges,10,3,Eggs,3,5" budget= 20 Sample Output 3: Costing in dictionary: {'Apples': 10, 'Oranges': 30, 'Eggs': 15} Total costing: 55 Total Budget: 20 Shopping not possible Explanation 3: The 1st product is Apples, and each apple costs 5 taka and 2 is the buying quantity of apples. So, the cost of apple is 5*2=10 taka. The 2nd product is Oranges, and each orange costs 10 taka and 3 is the buying quantity of oranges. So, the cost of Oranges is 10*3=30 taka. The 3rd product is Eggs, and each egg costs 3 taka and 5 is the buying quantity of eggs. So, the cost of eggs is 3*5=15 taka. So, total costing= 10+30+15=55 taka which is greater than the budget 20. So, You can NOT buy these items

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Assume, you have been given a string that contains a few products name, prices, and,
costing respectively, and an integer value as a budget for shopping.
Now, write a python program that will calculate the total costing of products from the given
string and check whether it is possible to buy those products while being within the budget.
If the total costing is greater than the budget, then print "Shopping not possible".
Otherwise, print "Yay!! Shopping possible".
If the quantity of any of the products is less than 1, then print "Quantity must be greater than
0".
ニニニニニ=ニニニ=
Given 1:
data = "Apples,5,2,0ranges,10,1,Eggs,3,5"|
budget= 70
Sample Output 1:
Costing in dictionary: {'Apples': 10, 'Oranges': 10, 'Eggs': 15}
Total costing: 35
Total Budget: 70
Yay!! Shopping possible
Explanation 1:
The 1st product is Apples, and each apple costs 5 takas and 2 is the buying quantity of
apples. So, the cost of apples is 5*2=10 taka.
The 2nd product is Oranges, and each orange costs 10 takas, and 1 is the buying quantity of
oranges. So, the cost of Orange is 10*1=10 taka.
The 3rd product is Eggs, and each egg costs 3 takas and 5 is the buying quantity of eggs.
So, the cost of eggs is 3*5=15 taka.
So, total costing= 10+10+15=35 taka which is less than the budget of 70. So, You can buy
these items.
ニニニ
Given 2:
data = "Apples,5,2,0ranges,10,0,Eggs,3,5"|
budget= 70
Sample Output 2:
Quantity must be greater than 0
Explanation 2:
Here Oranges buying quantity is 0. According to the given condition, costing calculation is
not possible.
======
==========
Given3:
data = "Apples,5,2,0ranges,10,3,Eggs,3,5"
budget= 20
Sample Output 3:
Costing in dictionary: {'Apples': 10, 'Oranges': 30, 'Eggs': 15}
Total costing: 55
Total Budget: 20
Shopping not possible
Explanation 3:
The 1st product is Apples, and each apple costs 5 taka and 2 is the buying quantity of
apples. So, the cost of apple is 5*2=10 taka.
The 2nd product is Oranges, and each orange costs 10 taka and 3 is the buying quantity of
oranges. So, the cost of Oranges is 10*3=30 taka.
The 3rd product is Eggs, and each egg costs 3 taka and 5 is the buying quantity of eggs. So,
the cost of eggs is 3*5=15 taka.
So, total costing= 10+30+15=55 taka which is greater than the budget 20. So, You can NOT
buy these items
Transcribed Image Text:Assume, you have been given a string that contains a few products name, prices, and, costing respectively, and an integer value as a budget for shopping. Now, write a python program that will calculate the total costing of products from the given string and check whether it is possible to buy those products while being within the budget. If the total costing is greater than the budget, then print "Shopping not possible". Otherwise, print "Yay!! Shopping possible". If the quantity of any of the products is less than 1, then print "Quantity must be greater than 0". ニニニニニ=ニニニ= Given 1: data = "Apples,5,2,0ranges,10,1,Eggs,3,5"| budget= 70 Sample Output 1: Costing in dictionary: {'Apples': 10, 'Oranges': 10, 'Eggs': 15} Total costing: 35 Total Budget: 70 Yay!! Shopping possible Explanation 1: The 1st product is Apples, and each apple costs 5 takas and 2 is the buying quantity of apples. So, the cost of apples is 5*2=10 taka. The 2nd product is Oranges, and each orange costs 10 takas, and 1 is the buying quantity of oranges. So, the cost of Orange is 10*1=10 taka. The 3rd product is Eggs, and each egg costs 3 takas and 5 is the buying quantity of eggs. So, the cost of eggs is 3*5=15 taka. So, total costing= 10+10+15=35 taka which is less than the budget of 70. So, You can buy these items. ニニニ Given 2: data = "Apples,5,2,0ranges,10,0,Eggs,3,5"| budget= 70 Sample Output 2: Quantity must be greater than 0 Explanation 2: Here Oranges buying quantity is 0. According to the given condition, costing calculation is not possible. ====== ========== Given3: data = "Apples,5,2,0ranges,10,3,Eggs,3,5" budget= 20 Sample Output 3: Costing in dictionary: {'Apples': 10, 'Oranges': 30, 'Eggs': 15} Total costing: 55 Total Budget: 20 Shopping not possible Explanation 3: The 1st product is Apples, and each apple costs 5 taka and 2 is the buying quantity of apples. So, the cost of apple is 5*2=10 taka. The 2nd product is Oranges, and each orange costs 10 taka and 3 is the buying quantity of oranges. So, the cost of Oranges is 10*3=30 taka. The 3rd product is Eggs, and each egg costs 3 taka and 5 is the buying quantity of eggs. So, the cost of eggs is 3*5=15 taka. So, total costing= 10+30+15=55 taka which is greater than the budget 20. So, You can NOT buy these items
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education