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
marin [14]
3 years ago
14

Write a program in python that can compare the unit (perlb) cost of sugar sold in packages with different weights and prices. Th

e program prompts the user to enter the weight and price of package 1, then does the same for package 2, and displays the results to indicate sugar in which package has a better price. It is assumed that the weight of all packages is measured in lb. The program should check to be sure that both the inputs of weight and price are both positive values.
Computers and Technology
1 answer:
Dmitrij [34]3 years ago
8 0

Answer:

weight1 = float(input("Enter the weight of first package: "))

price1 = float(input("Enter the price of first package: "))

weight2 = float(input("Enter the weight of second package: "))

price2 = float(input("Enter the price of second package: "))

if weight1 > 0 and price1 > 0 and weight2 > 0 and price2 > 0:

   unit_cost1 = price1 / weight1

   unit_cost2 = price2 / weight2

   

   if unit_cost1 < unit_cost2:

       print("Package 1 has a better price.")

   else:

       print("Package 2 has a better price.")

else:

   print("All the entered values must be positive!")

Explanation:

*The code is in Python.

Ask the user to enter the weight and the price of the packages

Check if the all the values are greater than 0. If they are, calculate the unit price of the packages, divide the prices by weights. Then, compare the unit prices. The package with a smaller unit price has a better price.

If all the entered values are not greater than 0, print a warning message

You might be interested in
______ is the primary and dominant cryptographic authentication and encryption framework for security development within the TCP
Kitty [74]

Answer:

"IP security" is the correct answer for the above question.

Explanation:

  • "IP security" is a set of rules or protocols which are used for the communication of the network.
  • It is a protocol that is used to encrypt the data which is needed to transfer on the network.
  • It provides security for the communication and it encrypts the data which is needs o transfer on the network.
  • The above question asked about the term which is used for encryption and security. So the answer is "IP security", which is defined above.
7 0
4 years ago
Read 2 more answers
__________ has become a widely accepted evaluation standard for training and education related to the security of information sy
kirill115 [55]
NSTISSI NO 4011 has become a widely accepted evaluation standard for training and education related to the security of information system. The standard is directed at information security professionals who are experts in identifying system vulnerabilities, investigating system security, documenting, analyzing and evaluating system security technology policies.<span />
4 0
3 years ago
What do these terms have in common? google, yahoo!, bing they are important books. they are internet search engines. they are wo
Vlada [557]
They are Internet search engines.
7 0
4 years ago
Why laptop computer is called micro computer?​
Eduardwww [97]

Answer:

A lot top is a microcomputer because Michael computer has all the devices that you can use

3 0
3 years ago
A(n) ________ is a light-sensitive material used to make a chip.
RSB [31]
The photoresist is a light-sensitive material used to make a chip. Photoresists can likewise be uncovered by electron shafts, creating an indistinguishable outcomes from introduction by light. The primary distinction is that while photons are consumed, storing all their vitality without a moment's delay, electrons store their vitality bit by bit, and scramble inside the photoresist amid this procedure.
3 0
4 years ago
Other questions:
  • ?the single most effective security measure for digital devices is to password protect access to them.
    5·1 answer
  • Suppose that the following regular expression is used to recognize real numbers in scientific notation in a programming language
    14·1 answer
  • Which of the following is the part of a digital camera that acts as the film?
    11·1 answer
  • How do I turn of the noise canceling feature on my beats studio wireless?
    13·1 answer
  • Technician A says copper has a low resistance. Technician B says the length of wire doesn't affect resistance. Who is correct?
    11·1 answer
  • During flashbacks you experience______.
    14·2 answers
  • QUESTION
    14·1 answer
  • Give an example of a situation in which shears would be the best choice and one in which scissors would suffice.
    14·1 answer
  • One of the prominent movies released in the 1950s is
    15·2 answers
  • Citing Wikipedia as a reference is not considered a good practice because 1.leverages a neutral point of view. 2.hosts unopinion
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!