1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Firdavs [7]
3 years ago
15

The add_prices function returns the total price of all of the groceries in the dictionary. Fill in the blanks to complete this f

unction (python):def add_prices(basket): # Initialize the variable that will be used for thecalculation total = 0 # Iterate through the dictionary items for ___: # Add each price to the totalcalculation # Hint: how do you access thevalues of # dictionary items? total += ___ # Limit the return value to 2 decimal places return round(total, 2)groceries = {"bananas": 1.56, "apples": 2.50, "oranges": 0.99,"bread": 4.59, "coffee": 6.99, "milk": 3.39, "eggs": 2.98, "cheese":5.44}print(add_prices(groceries)) # Should print 28.44
Computers and Technology
1 answer:
Vlada [557]3 years ago
8 0

Answer:

def add_prices(basket):

 

   total = 0

   for items in basket.values():

       total += items

   return round(total, 2)

groceries = {"bananas": 1.56, "apples": 2.50, "oranges": 0.99,"bread": 4.59, "coffee": 6.99, "milk": 3.39, "eggs": 2.98, "cheese":5.44}

print(add_prices(groceries)) # Should print 28.44

Explanation:

The python dictionary is a data structure that stores items of data as a key-value pair. The keys and values can be listed separately using the keys() and values() built-in function.

The program above uses a for loop statement to iterate over the values of the groceries dictionary to return the total sum of the values.

You might be interested in
What is the value of |-10|
Goshia [24]
Its 10, value always has to be positive.
6 0
3 years ago
Margaret would like to work in the Journalism and Broadcasting industry. Which set of qualifications would best assist Margaret
8_murik_8 [283]
Critical thinking, accuracy and confidence
7 0
3 years ago
Read 2 more answers
Selecting the Tiled windows arrangement option places the windows in a(n) _______ pattern on the screen.
Archy [21]

Answer:

Selecting the Tiled windows arrangement option places the windows in a(n) Grid pattern on the screen.

Explanation:

3 0
2 years ago
What is another term for additive manufacturing
Ira Lisetskai [31]

Answer:

Contact Us. Additive manufacturing (AM) or additive layer manufacturing (ALM) is the industrial production name for 3D printing, a computer controlled process that creates three dimensional objects by depositing materials, usually in layers.

Explanation:

6 0
3 years ago
What affect did the Scopes trial have on the school curriculum in Tennessee?
Bad White [126]
D)It did not change the curriculum because Scopes lost the case.
4 0
3 years ago
Read 2 more answers
Other questions:
  • When might it be necessary or advisable to write a shell script instead of a shell function? give as many reasons as you can thi
    15·1 answer
  • If you don't know whether to write too, two, or to, you should use the spell-checker to help you decide. true or false?
    7·1 answer
  • What were the goals of the “paperless society” ideal?
    14·2 answers
  • Suppose the file is sent continuously as one big message. how long does it take to send the file, assuming it is sent continuous
    15·1 answer
  • The parallax perspective says that objects that are close up appear to move __________ than far away objects.
    10·1 answer
  • Most smartphones use operating systems developed by ________. Select one: A. Symbian and Apple B. Apple and Microsoft C. Microso
    13·1 answer
  • What is the WiFi signal strength in different iPhone models?
    7·1 answer
  • What component of a processor holds instructions waiting to be processed by the alu?
    11·1 answer
  • Which of these parts serves as the rear cross structure of a vehicle?
    12·1 answer
  • ANSWERED CORRECT BELOW
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!