Question
Question-2: Assume, you have been given a string that contains a few products name, prices, and, costing respectively, and an integer value as a budget
Question-2: 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,Oranges,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,Oranges,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,Oranges,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.
(I need the answer in Python) Please send it fast.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started