Computer Science, asked by ayyalusamy1975, 7 months ago

Write a program that repeatedly asks the user to enter product names and prices. Store all of them in a dictionary whose keys are product names and values are prices. And also write a code to search an item from the dictionary.

Answers

Answered by jai696
9

\huge\red{\mid{\fbox{\tt{Using\: Python\: 3}}\mid}}

products = {}

search = lambda product: products[product] if product in products else None

for _ in range(10):

product, price = input("product: "), float(input("price: "))

products[product] = price

print()

print("Price: ", search((product := input("search product: "))))

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Answered by amritamohanty918
2

Answer:

products = {}

products = {}search = lambda product: products[product] if product in products else None

products = {}search = lambda product: products[product] if product in products else Nonefor _ in range(10):

products = {}search = lambda product: products[product] if product in products else Nonefor _ in range(10):product, price = input("product: "), float(input("price: "))

products = {}search = lambda product: products[product] if product in products else Nonefor _ in range(10):product, price = input("product: "), float(input("price: "))products[product] = price

products = {}search = lambda product: products[product] if product in products else Nonefor _ in range(10):product, price = input("product: "), float(input("price: "))products[product] = priceprint()

products = {}search = lambda product: products[product] if product in products else Nonefor _ in range(10):product, price = input("product: "), float(input("price: "))products[product] = priceprint()print("Price: ", search((product := input("search product: "))))

Similar questions