In: Computer Science
Create a Python program that:
Save the program and submit it to this site for grading.
SOLUTION-
I have solve the problem in python code with comments and
screenshot for easy understanding :)
CODE-
#python code
#Main function
def main():
    #Empty list
    l=[]
    #taking inputs from user
    name=input("Enter item name:")
    quantity=int(input("Enter item
quantity:"))
    price=float(input("Enter item price:"))
    #Printing all details of item
    print("name= ",name)
    print("Quantity= ",quantity)
    print("Price= ",price)
    #Calculating and displaying extended
price=quantity*price
    e=quantity*price
    #storing extended price of each item in
list
    l.append(e)
    print("Extended price= ",e)
    #Taking name of the file as input from
user
    f_name=input("Enter the filename in which you
want to save data...")
    #opening that file in write mode as calculation
is done only on the item
    # stored in one execution of program
  
    file=open("{}.txt".format(f_name),'w')
    #While loop
    while(1):
        #Storing all the details
of item in that file with , in between
       
file.write(name+",")
       
file.write(str(quantity)+",")
       
file.write(str(price)+",")
       
file.write(str(e)+"\n")
        #Asking user if they
wants to add more items
        i=input("Do you want to
add more items?(y/n)")
        #if yes then again take
input of all details of the items and
        #storing it in file in
next iteration of loop as the loop continues
        if(i=="y" or
i=="Y"):
           
name=input("Enter item name:")
           
quantity=int(input("Enter item quantity:"))
           
price=float(input("Enter item price:"))
           
print("name= ",name)
           
print("Quantity= ",quantity)
           
print("Price= ",price)
           
e=quantity*price
           
l.append(e)
           
print("Extended price= ",e)
        #otherwise close the
file and come out of loop
        elif(i=="n" or
i=="N"):
           
file.close()
           
break
    #Printing total sales stored in that list
l
    print("Sales total= ",sum(l))
    #if total sales >$100
    if(sum(l)>100):
        a=sum(l)
        #10% discount
        dis=a/10
        #sales after
discount
        sales=a-dis
        #printing discount
        print("Discount=
",dis)
        #8% sales tax on the
sale after discount
       
sales_tax=sales*8/100
        #printing sales
tax
        print("Sales Tax=
",sales_tax)
        #Total sale after
discount and sales tax addition
        s=sales+sales_tax
        #Displaying final
sales
        print("Total sales after
discount and sales tax addition = ",s)
#calling main function
main()
SCREENSHOT-


f.txt -

OUTPUT -

IF YOU HAVE ANY DOUBT PLEASE COMMENT DOWN BELOW I WILL
SOLVE IT FOR YOU:)
----------------PLEASE RATE THE ANSWER-----------THANK
YOU!!!!!!!!----------