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
A sales transaction was coded with an invalid customer account code (XXX-XX-XXX rather than XXX-XXX-XXX). The error was not dete
GenaCL600 [577]

Answer:

a simple IF statement using Regex

Explanation:

In any coding language, a good control procedure for this would be a simple IF statement using Regex. In the IF statement you can grab the account code and compare it to a regular expression that represents the correct format. IF the account code is in the correct format (matches the regular expression), then you go ahead and save the account code for use. Otherwise, you would output an error and ask for another account code. This will prevent the program from trying to use an account code that is not valid.

5 0
3 years ago
Guys im getting the ps5 tomorrow :)​
Paha777 [63]

Answer:

lucky mf

Explanation:

5 0
2 years ago
Read 2 more answers
Choose the reasons why Windows Server operating systems are a popular choice for a network because they _____. Select all that a
solong [7]

Answer:

Windows Server operating systems are a popular choice for a network because they use wizards and setup devices as the user operating system, making it easier to set up network features work on networks that include using Windows operating systems as well as Mac OS, NetWare, or UNIX

Explanation:

Windows operating system is popular than any other operating system for certain reasons:

1. It provides GUI feature which any layman can access and learn easily

2. The compatibility that it provides makes it more popular

3. It supports most of the software program available in the market

4. The design of Windows is more comfortable when compared to other open source operating system.

Only thing is that it is not a free-ware. Licence needs to be purchased to use it.

6 0
3 years ago
(1) Experiment Purpose
ra1l [238]

An Output report is known to be the various  findings that has been generated or it is said to be the result of a given program outcome.

<h3>What is an output report?</h3>

An output is known to be a file that has been produced by the system when a user is said to have submitted a Program, Report Set, etc. for execution.

Note that to be able to compile the GPSSWorld program, one has to use a statistical software to create the output and charts, and then one can copy and paste the results unto any given  word processor software where one can construct a table for it.

Learn more about output reports from

brainly.com/question/11599232

#SPJ1

3 0
1 year ago
A leading pharmaceutical company is launching a major transformation of its entire Cloud operations in order to more quickly and
Deffense [45]

A cloud-first strategy helps this client by providing a data-centric approach that offers more speed, agility, and security. Thus, the correct option is B.

<h3>What is a Cloud-first strategy?</h3>

A cloud-first strategy may be defined as an operational strategy that allows the users to reposition all or most of their infrastructure to cloud-computing platforms.

A cloud-first strategy helps this client in numerous ways. It provides a data-centric approach that offers more speed, agility, and security to its customers or clients in a facilitated manner.

Therefore, the correct option for this question is B.

To learn more about the Cloud-first strategy, refer to the link:

brainly.com/question/24719487

#SPJ1

7 0
1 year ago
Other questions:
  • what aspect should you consider before adding pictures to a document? you should structure the first before you search for a rel
    15·2 answers
  • Who was eqvtime tayaishvili?​
    13·2 answers
  • What tasks do most operating systems perform?
    15·1 answer
  • An inventory clerk, using a computer terminal, views the following on screen: part number, part description, quantity on hand, q
    8·1 answer
  • A collection of computers and other hardware devices that are connected together to share hardware, software, and data, as well
    15·1 answer
  • Can anyone can tell me and explain me the answer of it please .<br>thanks
    9·1 answer
  • Are the buying and selling of stocks centralized activities? Why or why not?
    10·2 answers
  • What is the result of expression 15 &gt; 10 &gt; 5 in C? What is the result of the same expression in Java?
    14·1 answer
  • The find_item functions uses binary search to recursively locate an item is the list, returning true if found, false otherwise.
    13·1 answer
  • What is boot sector virus​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!