Ответ:
products = {
"product1": {"weight": 2.5, "total_cost": 9.0},
"product2": {"weight": 3.0, "total_cost": 10.5},
"product3": {"weight": 1.0, "total_cost": 5.0}
}
product_name = input("Enter the name of the product: ")
if product_name in products:
product = products[product_name]
cost_per_kg = product["total_cost"] / product["weight"]
print("The cost of 1 kg of {} is {:.2f}".format(product_name, cost_per_kg))
else:
print("The entered product name is not valid.")
Объяснение:
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
products = {
"product1": {"weight": 2.5, "total_cost": 9.0},
"product2": {"weight": 3.0, "total_cost": 10.5},
"product3": {"weight": 1.0, "total_cost": 5.0}
}
product_name = input("Enter the name of the product: ")
if product_name in products:
product = products[product_name]
cost_per_kg = product["total_cost"] / product["weight"]
print("The cost of 1 kg of {} is {:.2f}".format(product_name, cost_per_kg))
else:
print("The entered product name is not valid.")
Объяснение: