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]
3 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]3 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
A kettle is boiled and the
Lynna [10]

Answer:

A 64°C

Explanation:

5 0
3 years ago
There are many different computer peripherals that are available to optimize your computing system’s specific needs. A graphic d
Rashid [163]

Answer:

Jamal could use a drawing pad. He could draw things out with a stylus and have it on his PC to manipulate. They cost as little as $40.

Felicia could use a mechanical keyboard. Although these are better for nearly everyone, someone who is doing a lot of typing and needing both speed and accuracy should get one. They start at around $50.

Credence could use a printer to print out work to hand in when needed. A decent one starts at around $100.

8 0
3 years ago
Which software application is most appropriate for creating slideshows using text, charts, photographs, clip art, and video? dat
Daniel [21]
I'd say powerpoint I always use this to show graphs and stuff
4 0
3 years ago
Read 2 more answers
Cloud computing service providers manage different computing resources based on the services they offer. Which resources do IaaS
eimsori [14]

Answer:

1. C.operating system

2. A.applications

Explanation:

1. The Iaas is the infrastructure as a service, and storage, server, and network are the infrastructures. However, the Operating System is the platform, and hence it is the correct option for the first blank. We need to understand the exact meaning of the IaaS, PaaS and the SaaS as well as MaaS, to better understand cloud computing.

2. In the second case, we have been asked about the option that is not being covered by the PaaS, and Paas stands for the platform as a service. And the interface, storage, and virtualization is the platform whereas the Applications is an example of software. And it is being managed by SaaS, Hence, the correct option is A. Applications.

7 0
3 years ago
Why was the microchip essential to improving computers?
-BARSIC- [3]
Because it downsized the scale of the computer itself.

5 0
3 years ago
Other questions:
  • Answer: x = 3<br>#1 -2x + 5 = -31​
    10·1 answer
  • You have been found at fault in a crash where someone was injured and was transported to a medical treatment facility. By law yo
    15·2 answers
  • Alto Innovations creates custom software for organizations. The company's managers want to build a high-performance culture in t
    11·1 answer
  • How do I make my own extension for chrome?
    7·1 answer
  • 4. What are five actions you should do to care for your camera?
    15·1 answer
  • PLEASE help me RIGHT NOW!!!!!!!!! I will give a Brainly to anyone who helps me!
    15·1 answer
  • How does white balancing affect the images recorded by a camera?
    15·1 answer
  • When you navigate inside a compressed folder, you click the
    6·1 answer
  • I need help, thank you
    5·1 answer
  • What is a registered degree
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!