(Financial: compare costs) Suppose you shop for rice and find it in two differentsized packages. You would like to write a program to compare the costs of the packages. The program prompts the user to enter the weight and price of each package and then displays the one with the better price. Here is a sample run:
Enter weight and price for package 1: 50, 24.59
Enter weight and price for package 2:25, 11.99
Package 1 has the better price.
SOURCE CODE:
# Enter weight and price for package1
print("Enter weight and price for package1 : ")
a=eval(input())
b=eval(input())
# Enter weight and price for package2
print("Enter weight and price for package2 : ")
c=eval(input())
d=eval(input())
# Checking for better price
if b > d:
print("Package 1 has the better price")
else:
print("Package 2 has the better price")
OUTPUT:
Enter weight and price for package1 :
20
50
Enter weight and price for package2 :
30
60
Package 2 has the better price