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
Katyanochek1 [597]
2 years ago
6

Write a program get_price.py with a function get_price() that takes a dictionary of fruits as an argument and returns the name o

f the most expensive fruit. Each item of the dictionary includes: A key: the name of the fruit A value: the price of the fruit.
Computers and Technology
1 answer:
yawa3891 [41]2 years ago
4 0

Answer:

The program is as follows:

def get_price(fruits):

   AllPrice = fruits.values()

   value_iterator = iter(AllPrice)

   mostExpensive = next(value_iterator)  

   for item in fruits:

       if fruits[item]>=mostExpensive:

           mostExpensive = fruits[item]

           fruitName = item

   print(fruitName)

fruits = {}

n = int(input("Number of Fruits: "))

for i in range(n):

   name = input("Fruit name: ")

   price = int(input("Fruit price: "))

   fruits[name] = price

get_price(fruits)

Explanation:

This defines the get_price function

def get_price(fruits):

This gets all price in the dictionary fruit

   AllPrice = fruits.values()

This passes the values to a value iterator

   value_iterator = iter(AllPrice)

This initializes mostExpensive to the first price in the dictionary

   mostExpensive = next(value_iterator)

This iterates through the elements of the dictionary  

   for item in fruits:

If current element is greater than or equals most expensive

       if fruits[item]>=mostExpensive:

Set most expensive to the current element

           mostExpensive = fruits[item]

Get the corresponding fruit name

           fruitName = item

Print fruit name

   print(fruitName)

The main begins here

This initializes the fruit dictionary

fruits = {}

This gets input for the number of fruits

n = int(input("Number of Fruits: "))

This is repeated for every inputs

for i in range(n):

Get fruit name

   name = input("Fruit name: ")

Get fruit price

   price = int(input("Fruit price: "))

Append name and price to dictionary

   fruits[name] = price

Call the get_price function

get_price(fruits)

You might be interested in
PLZ HELP ME ITS URGENT PlZ PLZ PLZ
Lubov Fominskaja [6]

Answer:

#include <stdio.h>

void main()

{

int num;

printf("Input a number :");

scanf("%d", &num);

if (num >= 0)

printf("%d is a positive number \n", num);

else

printf("%d is a negative number \n", num);

}

Explanation:

good luck.

hope it helped you.

pls mark brainleist

8 0
2 years ago
When patel’s advertising co. decided to upgrade its computer network, many people were involved in the decision. In b2b buying s
babunello [35]

In b2b buying systems, decisions are often made by by a committee after a lot of considerable deliberation.

<h3>What is Business-to-Business service?</h3>

Business-to-business is known to be a kind of a scenario where one business is said to often makes a commercial transaction with another kind of business.

The B2B decision-making process is known to be made up of some discrete tasks such as:

  • Knowing that there is an issue or need.
  • Examining  and comparing the available alternative or solutions
  • Defining the requirements that is needed for the product and others.

Hence, In b2b buying systems, decisions are often made by by a committee after a lot of considerable deliberation.

Learn more about b2b from

brainly.com/question/26506080

#SPJ1

4 0
1 year ago
_______ are special incentives or excitement-building programs that encourage consumers to purchase a particular product, often
Damm [24]

Answer: sales promotion

Explanation:

Sales promotion are special incentives or excitement-building programs that encourage consumers to purchase a particular product, often used in conjunction with advertising or personal selling programs.

5 0
3 years ago
What is the value of y when this code executes?
Cerrena [4.2K]

Answer:

The operation of 6*x only executes if x is greater or equal to 0, since x=-10 and -10 is less than 0, the operation does not execute. For this reason,  the value of y using this code is None.

Explanation:

In python a function is defined with the syntaxis:  

def function(x):  

the operation to execute (x)

value to return

In this case, the function is foo and the parameter is x:  

def foo(x):

  if x>= 0:

     return 6*x

The code starts by assigning a value to x. Then, the code asks if the value of x is grater or equal to 0, if this condition is meet, then the code returns the value of 6 times x, if not, then the code does not return a value. In this case, x is -10 and this value is not grater or equal to 0. Given that the condition is not met, then the code stops executing and the value of y is none.

4 0
2 years ago
Janelle is organizing an outline for an investigative report about the benefits of taking a 30-minute walk each day. which of th
Xelga [282]

Answer:

Err. I'm getting vibes from C.

Explanation:

Janelle is organizing an outline for an investigative report about the benefits of taking a 30-minute walk each day.

Benefits - Good/Helpful

8 0
2 years ago
Read 2 more answers
Other questions:
  • Someone help me I don’t know what to do /COMPUTER SCIENCE
    5·1 answer
  • What component has the job of managing data as it flows into and out of the places it needs to go?
    11·2 answers
  • Number Array Class
    5·1 answer
  • JAVA
    12·1 answer
  • Where do charts get the data series names?
    14·1 answer
  • What is said to be the first mechanical calculator​
    7·2 answers
  • For the sake of maximizing hardware utilization in a multicore system with a many to many threading model, the relationship of t
    12·1 answer
  • Type the numbers 1-50 and then type Computers and Technology twice type it once forward and once backwards.
    5·2 answers
  • What what do these two parts of the lift do ​
    14·1 answer
  • Language modeling incorporates rules of __. Select all that apply.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!