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
Maxwell says three things Level Two Leaders do well are:
IRINA_888 [86]

Answer:

true

Explanation:

3 0
3 years ago
Which keyboard shortcut can you use to copy data from a cell? HURRY UP PLZ RIGHT NOW HURRY.
Romashka-Z-Leto [24]
The keyboard shortcut used to copy data from a cell is A.) Ctrl + c command +C

I hope this helped!! :)
7 0
3 years ago
Read 2 more answers
A wireframe is a sketch detailing where text and images will be placed on a website. T/F
kirill115 [55]
Your answer would be true. 
3 0
3 years ago
Grenstall Inc., a software development firm, has adopted a new job evaluation system in which managers are asked to objectively
rosijanka [135]

Answer:

Grenstall is most likely using the point system

Explanation:

The point system is a method of job evaluation system that involves measuring performance of workers in an organization and allocating points to identifiable factors such as skills, efforts, training, knowledge and experience based on its performance. It does not focus on entire job functions. The allocated points enables the organization to determine the compensation that is commensurate for a particular position.

Greenstall Inc uses the point system technique of job evaluation system for its managers as their jobs were broken down based on their skills, mental and physical efforts, training, and responsibility with points being allocated to each of these factors which are then summed up.  

7 0
3 years ago
________ is the amount of data that can be transmitted across a transmission medium in a certain amount of time.
USPshnik [31]
The correct word here is BANDWIDTH. Bandwidth refers to the quantity of information that a connection to the internet can handle in a given time. For digital devices, the unit of bandwidth is bytes per second. For analog devices it is expressed as cycle per second or Hertz.
6 0
3 years ago
Other questions:
  • Which of the following statements is true of a database? a. It is a collection of unstructured data. b. It is accessed primarily
    14·1 answer
  • You are able to change the formatting of a table after it is inserted into a placeholder. True or false
    9·2 answers
  • The presentation ____ determines the formatting characteristics of fonts and colors.
    11·2 answers
  • Based on current and upcoming gaming technologies, what changes do you expect to see in the next generation of gaming consoles?
    6·1 answer
  • Which icon is greater in file size? (Show your working)
    8·1 answer
  • If you give an actual answer I'll give brainliest​
    13·2 answers
  • What is the long tube on a microscope called​
    15·1 answer
  • What is 5 times 5 times 16 times 11 2345
    6·2 answers
  • Jim is working on a network design for a small office running a Windows file and printer server with Internet
    15·1 answer
  • How do i delete cookies on a chromebook?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!