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
Write a program that asks the user for three names, then prints the names in reverse order.
sasho [114]

Answer:

The program written in C++ is as follows'

#include<iostream>

using namespace std;

int main()

{

string names[3];

cout<<"Please enter three names: "<<endl;

for (int i = 0; i< 3;i++)

{

cin>>names[i];

}

for (int i = 2; i>= 0;i--)

{

cout<<names[i]<<endl;

}

return 0;

}

Explanation:

This line declares an array for 3 elements

string names[3];

This line prompts user for three names

cout<<"Please enter three names: "<<endl;

This following iteration lets user input the three names

for (int i = 0; i< 3;i++)  {  cin>>names[i];  }

The following iteration prints the three names in reverse order

for (int i = 2; i>= 0;i--)  {  cout<<names[i]<<endl;  }

8 0
3 years ago
Who loves you tube , anyone?
kodGreya [7K]

I LIKE IT DO YOU ALSO LOVE IIT

8 0
3 years ago
Read 2 more answers
What gaming PC should I get
zhuklara [117]

Answer:

ps5

Explanation:

8 0
2 years ago
Read 2 more answers
What technology has a function of using trusted third-party protocols to issue credentials that are accepted as an authoritative
jarptica [38.1K]

Answer: PKI certificates

Explanation: PKI is known as the public key infrastructure which is commonly used for the encryption of the data and also for the data signing. They have the ability to assign the keys pair.

PKI certificates are in the form of strings of alpha-numeric running for a mathematical functions. They use the third party protocols for the execution and they are widely accepted by the authoritative identity.

5 0
2 years ago
Imagine that you work for a company directly related to your major. Your company is preparing for expansion and your boss, Ms. S
shutvik [7]

Answer:

start with what you know

Explanation:

6 0
2 years ago
Other questions:
  • Windows uses a graphical user interface (GUI), which means: a user can carry out commands by clicking, dragging, or otherwise ma
    6·1 answer
  • If you have a list of words that you wish me to make into a bulleted list, you must first highlig or ______ The words with the c
    13·1 answer
  • When creating a presentation you should use a blank as a starting point?
    15·1 answer
  • Some numbers are formed with closed paths. the digits 0, 4, 6 and 9 each have 1 closed path and 8 has 2. None of the other numbe
    6·1 answer
  • Lifelong learning _____. is only important for professionals with advanced degrees can be formal or informal includes formal cla
    12·1 answer
  • I'm gonna get grounded for getting a 52 on my test :(
    13·1 answer
  • List at least 5 professions for people working in the Information/Communication<br> fields.
    10·1 answer
  • Guys im getting the ps5 tomorrow :)​
    5·2 answers
  • You are the IT administrator for a small corporate network. The employee in Office 2 is setting up a virtualization environment
    10·1 answer
  • True or False: At the Company level, users will only have access to view projects to which they have been specifically granted a
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!