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
Print("Weight on Earth?")
Lynna [10]

Answer:

weightEarth = float(input("Enter weight on earth: "))

weightMoon = weightEarth/6

print("Weight on moon:", weightMoon)

Explanation:

You have to convert the string input into a float in order to do calculations with it.

5 0
2 years ago
In the maintenance phase of the waterfall model, the parts of a program are brought together into a smoothly functioning whole,
vivado [14]

Answer:

False

Explanation:

The maintenance phase of the waterfall model for software development involves making changes to the entire system or some parts of it for improved performance. Integration and testing is the step at which  all units developed at the implementation stage are brought together to form a whole functioning system. At this stage, the system is constantly checked for proper functionality so it can be deployed.

7 0
3 years ago
Which process improves the life of a computer?
arlik [135]

maintenance is the answer

3 0
3 years ago
Notice that the percentages range from just over 55% to just under 65%. This is a range of 10%, so we're going to use 5 evenly-s
vfiekz [6]

Answer:

import numpy as np

l_int = 55/100

h_int = 65/100

hist = np.histogram( paid_tax_preparers_list, bins=5, range=(l_int, h_int))

Explanation:

Numpy is a Python package used to ease mathematical and statistical research calculations. The package creates data structures called arrays that can be used as vector items, making it easy and fast for calculation to be done.

The np.histogram method is used to create or plot histograms of a list or array against the frequency of the items in the array. The bins and the range attributes are used to adjust the display of the histogram, with bins being the number of bin in the graph and range is the given length of the histogram.

7 0
3 years ago
2.<br> The force of impact is
NNADVOKAT [17]

Answer:

lực ( Tiếng Anh : force ) là bất kỳ ảnh hưởng nào làm một vật thể chịu sự thay đổi, hoặc là ảnh hưởng đến chuyển động, hướng của nó hay cấu trúc hình học của nó.

Explanation:

7 0
3 years ago
Other questions:
  • In a case where electrical current leakage from the circuit occurs,
    7·2 answers
  • What could prevent earmuffs from providing your ears good protection from noise?
    10·1 answer
  • Behaving in an acceptable manner in a workplace environment is referred to as workplace etiquette.
    12·2 answers
  • Assume you're running a query on your orders in the past year. You want to see how many orders were placed after May. What type
    5·1 answer
  • "The effectiveness of memory retrieval is directly related to the similarity of cues present when the memory was encoded to the
    11·1 answer
  • Software that helps users to communicate with family, friends and business colleagues by posting personal information, status up
    13·2 answers
  • Please help me I don’t know what to do
    13·2 answers
  • 10.7 LAB: Fat-burning heart rate Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus th
    8·1 answer
  • Draw a circuit with a 12-volt battery, a 100 ohms resistor in series, and two resistors (each of value 200 ohms) in parallel. Wh
    9·1 answer
  • A _____ is the viewing area for a web page, which is much smaller on a phone than on a traditional desktop.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!