+ 1

Does anyone know how I start this in python

Suppose you shop for rice in two different packages. You would like to write a program to compare the cost. The program prompts the. user to enter the weight and price of the each package and displays the one with. the better price weight 1 = 50 price for package 1= 24.59 weight 2 = 25 price for package 2 =11.99

14th Feb 2018, 6:26 PM
Phil Rinaldi
Phil Rinaldi - avatar
2 Answers
+ 1
That's just basic math fractions: you need to compute for each package the cost for same amount, usually the unit, so: Does anyone know how I start this in python Suppose you shop for rice in two different packages. You would like to write a program to compare the cost. The program prompts the. user to enter the weight and price of the each package and displays the one with. the better price weight_1 = 50 price_package_1= 24.59 weight_2 = 25 price_package_2 =11.99 absolute_price_package_1 = price_package_1 / weight_1 absolute_price_package_2 = price_package_2 / weight_2 if (absolute_price_package_1 < absolute_price_package_2) better_cost_package = 1 else if (absolute_price_package_1 > absolute_price_package_2) better_cost_package = 2 else better_cost_package = 0 so, better_cost_package contains the number of better cost package, or zero if both are same ^^
15th Feb 2018, 7:19 AM
visph
visph - avatar
0
package1= eval(input("Enter the weight and cost of Package1 please: ")) package2= eval(input("Enter the weight and cost of Package2 please: ")) if package1 < package2: print("Package2 is the better option") if package2 < package1: print("Package1 is the better option") if package2 == package1: print("No difference between the two packages") --------- Not sure if this is the best option to compare the two, however, it works.
1st Mar 2020, 3:27 AM
Zachary C