In: Computer Science
Create a python program that:
Below is a screen shot of the python program to check indentation. Comments are given on every line explaining the code.Below is the output of the program:
Below is the code to copy: #CODE STARTS HERE----------------
#input file name
file_name = input("Enter file name: ")
file = open(file_name, "a+")
total_cost = 0 #Set total cost to 0
while True: #loops until user enters "n"
   #Get input
   name = input("\nEnter item name: ")
   quantity = int(input("Enter item quantity: "))
   price = float(input("Enter item price: "))
   #Calculate total cost
   extended_price = price*quantity
   total_cost += extended_price
   #Print item details
   print("\nItem name:",name)
   print("Item quantity:",quantity)
   print("Item price:",price)
   print("Item extended price:", extended_price)
   #Write items to the file
   file.write(name+","+str(quantity)+","+str(price)+","+str(price*quantity)+"\n")
   #Ask user for another item
   add_item = input("Do you want to add another item?(y/n)")
   if add_item.lower() == "n":
      file.close() #Close file
      break #break out of the loop
#print total cost
print("\nTotal cost: ",total_cost)
#Calculate and print discount
if total_cost > 100:
   discount = total_cost*0.1
   print("Discount :", discount)
   total_cost -= discount
   print("Total cost after discount: ",total_cost)
#Calsulate and print tax and grand total
print("Sales tax: ", total_cost*0.08)
total_cost = total_cost * 1.08
print("Grand total: ", round(total_cost,2))
#CODE ENDS HERE------------------