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
_____ is a higher-level, object-oriented application interface used to access remote database servers
makkiz [27]
RDO.

RDO uses the lower-level DAO and ODBC for direct access to databases.
7 0
1 year ago
The National Archives is part of the federal government, which means that its content:
RUDIKE [14]

Answer:

belongs to everyone.

Explanation:

A National Archive can be defined as the collection of data (informations) and documents by the government of a particular country for record keeping purposes.

Basically, these documents comprises of information about important and historical events that have happened in the country or events generally related with the country.

Hence, the National Archives is part of the federal government, which means that its content belongs to everyone. This is simply because the federal government is a government of the people, for the people and by the people. Thus, the ownership of governmental institutions or agencies belongs to the general public i.e the citizens of the country.

4 0
3 years ago
What permanent magnets of a motor are replaced with more powerful ones, what effect do you think this would have on motor rotati
Marat540 [252]
When permanent magnets of a motor are replaced with more powerful ones, the motor rotation will increase. This is because there is more electricity being generated.
7 0
3 years ago
Read 2 more answers
A document with a horizontal dimension greater than its vertical dimension is in _____ orientation.
Juli2301 [7.4K]
The answer is Portrait, or Option Choice C.


Diagonal can be relative to any shape

Sideways can be relative to any shape

Portrait is usually more vertical than horizontal because it is used to depict a person, usually stopping at the bottom of the torso

By process of elimination, Landscape is the answer.  Also, its because Landscape is usually used to depict the Land scape.   What a surprise.  And as you know, their is only so far you can paint vertically , but there is much more to paint horizontally.  Making the canvas more horizontal than vertical.<span />
8 0
3 years ago
Read 2 more answers
You have a MySQL database running on an EC2 instance in a private subnet. You can connect via SSH, but you are unable to apply u
AnnZ [28]

Answer:

Ensure that "Source/Destination Checks" is disabled on the NAT instance.

Explanation:

A NAT (Network Address Translation) instance is, like a bastion host, an EC2 instance that lives in your public subnet. A NAT instance, however, allows your private instances outgoing connectivity to the internet while at the same time blocking inbound traffic from the internet.

Many people configure their NAT instances to allow private instances to access the internet for important operating system updates. Patching your OS is an important part of maintaining instance level security.

NAT device enables instances in a private subnet to connect to the Internet or other AWS services, but prevents the Internet from initiating connections with the instances.

NAT devices do not support IPv6 traffic, use an egress-only Internet gateway instead.

5 0
3 years ago
Other questions:
  • Jason is working on a project that requires him to manage a huge amount of data. The spreadsheet he is working on has data relat
    12·1 answer
  • John would like to move from the city into the suburbs and has been saving up a large down payment for a home. Which is the most
    7·1 answer
  • a limited-access expressway. A)allows vehicles to enter or exit only at certain place.B) does not permit trucks or buses.C)has n
    9·1 answer
  • What are ip addresses? why are these important for forensic scientists?
    5·1 answer
  • (PLATO) How can hackers obtain a person’s data? Malicious hackers can obtain a person’s data through the method of simple ___ en
    7·1 answer
  • I need help with Python. The first image is the code and the 2nd is the output.
    8·1 answer
  • * 8) Embedded operating systems are specialized software meant only to manage the
    7·1 answer
  • You want to be able to identify the services running on a set of servers on your network. Which tool would best give you the inf
    11·1 answer
  • In a mobile phone network, how many times as strong would
    6·1 answer
  • Your organization has 20 employees who need an accounting software update installed. Due to a miscommunication, the purchaser on
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!