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]
2 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]2 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
90 POINTS Hazel is working with a database to help determine if the company she works for is making or losing money. Hazel has o
VikaD [51]

Answer:

a

Explanation:

5 0
2 years ago
Read 2 more answers
You may see the term FAQ on websites which stands for Frequently Asked Questions this is an example of which type of mnemonic?
babymother [125]
The first question is B.), acronym, and the second one is c.) acrostic.
Hope this helps!
6 0
3 years ago
Write an expression that executes the loop while the user enters a number greater than or equal to 0.
LekaFEV [45]

Answer:

while (userNum >=0) {...}

Explanation:

In a <u>while loop</u>, <u>the loop is executed until the condition is false</u>.

Since the loop will execute while the user enters a number greater than or equal to 0 (and that number is declared as <em>userNum</em>), we need to check if <em>userNum</em> is greater than or equal to 0.

4 0
3 years ago
What are the five generations of computer software​
Lerok [7]

Answer:

1st gen: Vacuum Tubes(1940–1956)

2nd gen: Transistors(1956–1963)

3rd gen: Integrated Circuits: (1964–1971)

4th gen: Microprocessors (1971–PRESENT)

5th gen: Artificial Intelligence (present)

Explanation:

8 0
2 years ago
Which of these files when included in a program will provide user assistance?
olya-2409 [2.1K]
What are the options for this answer? 
8 0
3 years ago
Read 2 more answers
Other questions:
  • In c++ 11, the ________ tells the compiler to determine the variable's data type from the initialization value.
    6·1 answer
  • Which network component blocks status?
    9·1 answer
  • A computer byte is the amount of data (measured in bits) that CPU can manipulate at one time/
    8·1 answer
  • What is ana absolute adress
    11·1 answer
  • WILL MARK CORRECT ANSWER AS BRAINLIEST PLSSSS HELP!
    13·2 answers
  • Describe the different non-printing characters,​
    11·1 answer
  • Which command could you use to change to the /usr directory using a relative pathname?
    8·1 answer
  • Acciones de un lápiz
    7·1 answer
  • Which of the following is an example of phishing attack? csp
    8·1 answer
  • The _____ of a story describes the time and location of a story.
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!