Home Page class 12 @ Python

CBSE Class 12 : Data Structures

Introduction to Data Structures

CBSE Class 12 : Searching

Creation And Traversal
What is Searching?
Linear/Sequential Search
Binary Search
Insertion Of Element
Deletion Of Element

CBSE Class 12 : Sorting

What is sorting?
Bubble Sort
Selection Sort
Insertion Sort

CBSE Class 12 : Stacks

Stacks
Applications of Stacks
Implementation of Stacks

CBSE Class 12 : Queues

Queues
Applications Of Queues
Implementation of Queues

Class 12 Data Structures | Queues 7

Maintaining student details like roll, name and per using Queues (Using Functions)

#queue implementation using functions
#program to create a queue of student(rollno,name,per).
"""
Add student
delete student
display details
"""
student=[]
def Add_student():
        rollno=input("Enter roll no  ")
        name=input("Enter name ")
        per=input("Enter percntage ")
        stu=(rollno,name,per)
        student.append(stu)
def del_student():
        if(student==[]):
                print("Underflow / student queue in empty")
        else:
                rollno,name,per=student.pop(0)
                print("poped element is ")
                print("Rollno ",rollno," name ",name," percentage ",per)
def traverse():
        if not (student==[]):
                n=len(student)
                for i in range(0,n):
                        print(student[i])
        else:
                print("Empty , No student to display")
while True:
        print("1. Add details of Student")
        print("2. delete details of student")
        print("3. Display details of students")
        print("4. Exit")
        ch=int(input("Enter your choice "))
        if(ch==1):
                Add_student()
        elif(ch==2):
                del_student()
        elif(ch==3):
                traverse()
        elif(ch==4):
                print("End")
                break
        else:
                print("Invalid choice")