In: Computer Science
A customer comes into a grocery store and buys 8 items. Write a PYTHON program that asks for the name of the item and the price of each item, and then displays these on the screen. Refer to the print() and input() statements covered in the module. Do NOT use loops as it will be covered in later modules. Apples 2.10 Hamburger 3.25 Milk 3.49 Sugar 1.99 Bread 1.76 Deli Turkey 7.99 Pickles 3.42 Butter 2.79
Python code:
#asking for item name
item1=input("Enter item name: ")
#asking for price
price1=input("Enter price: ")
#asking for item name
item2=input("Enter item name: ")
#asking for price
price2=input("Enter price: ")
#asking for item name
item3=input("Enter item name: ")
#asking for price
price3=input("Enter price: ")
#asking for item name
item4=input("Enter item name: ")
#asking for price
price4=input("Enter price: ")
#asking for item name
item5=input("Enter item name: ")
#asking for price
price5=input("Enter price: ")
#asking for item name
item6=input("Enter item name: ")
#asking for price
price6=input("Enter price: ")
#asking for item name
item7=input("Enter item name: ")
#asking for price
price7=input("Enter price: ")
#asking for item name
item8=input("Enter item name: ")
#asking for price
price8=input("Enter price: ")
#printing item name and price it item 1
print(item1+" "+price1)
#printing item name and price it item 2
print(item2+" "+price2)
#printing item name and price it item 3
print(item3+" "+price3)
#printing item name and price it item 4
print(item4+" "+price4)
#printing item name and price it item 5
print(item5+" "+price5)
#printing item name and price it item 6
print(item6+" "+price6)
#printing item name and price it item 7
print(item7+" "+price7)
#printing item name and price it item 8
print(item8+" "+price8)
Screenshot:
Input and Output: