Python Tutorial @ Home

#### Data Structures In Python

Data Structures In Python

# Python|Queues|Maintaining Bank details

Maintaining Bank details

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

Operations

Creation of empty queue

bank=[]

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).
"""
delete bank
traverse / display all bank
"""
bank=[]
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("2. Delete element");
print("3. Traversal")
print("4. Exit")
if(ch==1):