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
Which of the following situations is least likely fair use
kolezko [41]

Answer:

Is there more to the question or is that it?

8 0
3 years ago
Read 2 more answers
First Person Who Answers Fast As Possible Will Be Marked As Brainiest ​
AleksandrR [38]

Answer:

Save a database object Ctrl+S or Shift+F12

Open an existing database   Ctrl+O or Ctrl+F12

To quit MS Access ALT+F4

Explanation:

7 0
4 years ago
Which of the following can be considered classifications of technology companies? (Select all that apply)
artcher [175]
The answer is A, B, and C.

D. is too broad a term that actually includes A-C. So in other words there is no company that specializes in "Technology"

There are companies that specialize in E-Commerce, Hardware, and Security.

I guess if you wanted to say Google and Apple are technology companies you could say that but even they would fit into a particular classification. Google would be a Search Engine technology, and Apple would probably still be considered a hardware company even though both companies are involved across all of the 3 subjects in the answer.
4 0
4 years ago
Jessica is working on a report for her art history class. She is using Microsoft Word for her report so that she can incorporate
Lana71 [14]

Answer:

Clicking the F4 button

Explanation:

The function keys or F keys are in most cases lined along the top of the keyboard and labeled F1 through F12. These keys act as shortcuts, performing certain functions.

The F4 button is a quick way to repeat the last command /action carried out.

For Jessica to continue applying this same style to additional headers, all she needs to do is click the Function Button F4 at the new location where she wants to apply Heading 1 Quick Style.

Other functions of the F4 button are:

  • Alt+F4 closes the program window currently active in Microsoft Windows.
  • Ctrl+F4 closes the open window or tab in the active window in Microsoft Windows.
8 0
3 years ago
Read 2 more answers
In a proper webpage, which tag holds all of a webpages visible HTML?
Evgen [1.6K]

Body.


head contains all of the data that we generally don't see.


Link is used to link to external stylesheets.


script is where you would type scrips.


doctype is used to tell the browser the document type.

6 0
3 years ago
Other questions:
  • Why is it important to bring standalone systems into the domain? 4?
    8·1 answer
  • A device that makes it possible for multiple customers to share one address is called a/n _____.
    15·1 answer
  • How many words fit on a double-spaced page?
    11·1 answer
  • Assign courseStudent's name with Smith, age with 20, and ID with 9999. Use the PrintAll member function and a separate cout stat
    14·2 answers
  • The ____________________ utility uses the Burrows-Wheeler Block Sorting Huffman Coding algorithm when compressing files.a) bzip2
    11·1 answer
  • Prompt the user to enter five numbers, being five people's weights. Store the numbers in an array of doubles. Output the array's
    5·1 answer
  • If you change the text to bold,you are changing the what?
    9·1 answer
  • The Publisher-Subscriber design pattern is used to create __________________ communication between software objects and is used
    13·1 answer
  • Can some one help me answer this question plz
    8·1 answer
  • Think about how you view your emails—either the email service you use yourself or an email service you would choose to use. Desc
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!