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
TRUE/FALSE. a good with many close substitutes is likely to have relativelyelastic correct demand, since consumers can easily ch
natta225 [31]

Yes, this is true. Close substitutes for a good will make the demand for that good more elastic, since consumers can easily switch to a different good if the price of the original good rises.

<h3><u>The Impact of Close Substitutes on Price Elasticity of Demand</u></h3>

The demand for a good with many close substitutes is likely to be relatively elastic. This is because when the price of the good increases, consumers can easily switch to one of the close substitutes, which limits the effect of the price increase on demand.

For instance:

  • If the price of a particular brand of cereal rises, consumers may decide to purchase a different brand of cereal as an alternative, rather than paying the higher price.

This ability to switch to a close substitute reduces the impact of the price increase on demand.

Elasticity is an important concept in economics and can be used to understand how prices and demand interact.

  • When demand is elastic, an increase in price will cause a large decrease in demand. This is because consumers have the ability to switch to close substitutes, which limits the effect of the price increase.
  • On the other hand, when demand is inelastic, an increase in price will cause only a small decrease in demand. In this case, consumers do not have close substitutes available, so they are more likely to continue purchasing the good despite the price increase.

Learn more about <u>Elasticity </u><u>of </u><u>Demand</u> at: brainly.com/question/5078326

#SPJ4

8 0
1 year ago
Home communication involves controlling systems such as heating, cooling, and security.
katen-ka-za [31]

Answer:

<em>A. True</em>

Explanation:

<em>Home communications involves automating home. It includes controlling the air-con,water heater, webcam, etc. A</em>

6 0
3 years ago
What is the radix transformation method?
alex41 [277]
A method of transformation that involves changing the radix or base of the original key and either discarding excess high-order digits (that is, digits in excess of the number desired in the key) or extracting some part of the transformed number.
4 0
3 years ago
Which of the following are characteristics of a cell
olganol [36]

Answer:

-occurs at the intersection of columns and  rows

-is a single unit for entering data on a  spreadsheet

-is located according to its cell reference or  cell address

Explanation:

A cell is a box in a spreadsheet program that contains information and each cell is identified using a cell reference that indicates the colum letter followed by the row number where the cell is located. So, according to this, the characteristics of a cell in a spreadsheet software are:

-occurs at the intersection of columns and  rows

-is a single unit for entering data on a  spreadsheet

-is located according to its cell reference or  cell address

5 0
3 years ago
Whats the relationship between the CPU and motherboard
Mashcka [7]

Answer:

Both perform processes vital to running the computer's operating system and programs -- the motherboard serves as a base connecting all of the computer's components, while the CPU performs the actual data processing and computing.

Explanation:

6 0
3 years ago
Other questions:
  • What two images did you have to add to the wds server to handle the windows installation?
    7·1 answer
  • )in the link based implementation of the ADT sorted list what is the worst case time efficiency of the remove method?
    7·1 answer
  • BOTH INTERNATIONAL &amp; INLAND Which procedure(s) shall be used to determine risk of collision?
    14·1 answer
  • Pleaseeee help me w this!
    10·1 answer
  • Enter key is also known as Return key. (True or false)
    13·2 answers
  • Which of these is one of the primary concerns for protecting your family when online?
    9·2 answers
  • The Python language uses a compiler which is a program that both translates and executes the instructions in a high-level langua
    15·1 answer
  • How do i change the default setting in word to no open in dark mode
    8·1 answer
  • Programming that relies on the use of objects and methods to control complexity and solve problems is known as what type of prog
    7·1 answer
  • If anyone knows how to code on python:
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!