Friday 12 February 2021

Practical no-18: - Write a menu driven program which insert, delete and display the details of a product such as pid, pname and price using Stack.

 '''

Practical no-18: -  Write a menu driven program which insert, delete and display

the details of a product such as pid, pname and price using Stack.

'''

Product=[ ]

c="y"

while(c=="y" or c=="Y"):

       print("1: Insert Product Details: ")

       print("2: Delete Product Details: ")

       print("3: Display Product Details: ")

       choice=int(input("Enter Your Choice: "))

       if(choice==1):

              pid=int(input("Enter Product Id: "))

              pname=input("Enter Product Name: ")

              price=float(input("Enter Product Price: "))

              Prd=(pid,pname,price)

              Product.append(Prd)

       elif(choice==2):

             if(Product==[ ]):

                print("Stack Empty")

             else:

                    print("Deleted Product is: ",Product.pop())

       elif(choice==3):

              L=len(Product)

              while(L>0):

                     print(Product[L-1])

                     L=L-1

       else:

              print("Wrong input")

       c=input("Do you want to continue?, Press 'y' to continue: ")

       









No comments:

Post a Comment