Python|Queues|Maintaining Bank details

Maintaining Bank details

like ano, name and bal, using Queues (Using Functions)

Operations

Creation of empty queue

bank=[]

Addition of element

def add_element():
        ano=input(“Enter ano “)
        name=input(“Enter name “)
        bal=input(“Enter bal “)
        bnk=(ano,name,bal)
        bank.append(bnk)

Deletion of element

def del_element():
         if(bank==[]):
               print(“Underflow / bank Queue in empty”)
         else:
               ano,name,bal=bank.pop(0)
               print(“poped element is “)
               print(“ano “,ano,” name “,name,” bal “,bal)

To check Queue is empty or not

if(bank==[]):
      print(“No Bank Record /Queue is empty”)
else:
      print(“Queue is not empty”)

Traversal operation

def traverse():
      if not (bank==[]):
           n=len(bank)
           for i in range(0,n):
                print(bank[i])
     else:
           print(“Empty , No bank records to display”)

#queue implementation (using functions)
 #program to create a queue of Bank(ano,name,bal).
"""
 add bank
 delete bank
 traverse / display all bank
"""
bank=[]
def add_element():
         ano=input("Enter ano  ")
         name=input("Enter name ")
         bal=input("Enter bal ")
         bnk=(ano,name,bal)
         bank.append(bnk)


def del_element():
        if(bank==[]):
                print("Underflow / bank Queue in empty")
        else:
                ano,name,bal=bank.pop(0)
                print("poped element is ")
                print("ano ",ano," name ",name," bal ",bal)


def traverse():
        if not (bank==[]):
                n=len(bank)
                for i in range(0,n):
                        print(bank[i])
        else:
                print("Empty , No bank records  to display")

while True:
        print("1. Add element");
        print("2. Delete element");
        print("3. Traversal")
        print("4. Exit")
        ch=int(input("Enter your choice "))
        if(ch==1):
                add_element()
        elif(ch==2):
                del_element();
        elif(ch==3):
                traverse()
        elif(ch==4):
                print("End")
                break
        else:
                print("Invalid choice")
                

Visitor Counter

0056754