Question: Write a Python program to create a dictionary called groceries with the values, items like rice, orange, and apple juice etc, take at least 5

Write a Python program to create a dictionary called groceries with the values, items like "rice", "orange", and "apple juice" etc, take at least 5 groceries items. Perform following task:

  • Define a function called calculate_bill that takes one argument food as input. In the function, create a variable total with an initial value of zero. For each item in the food list, add the price of that item to total. In the end, return the total as output.

  • Make the following changes to your calculate_bill function: While you loop through each item of food, only add the price of the item to total if the item's price is greater than 20. Also add 3 more items in your grocery items and remove 2 less price items in your previous groceries item. Fetch the final output

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!