0% found this document useful (0 votes)
4 views6 pages

Practical File Format

This document is a practical file for Computer Science (083) for the term 2025-26, submitted by a student at Rosary Senior Secondary School. It includes a Python program that implements a stack using a list, detailing functions for pushing, popping, and displaying stack contents. The document also provides sample input and output demonstrating the program's functionality.

Uploaded by

teotiavansh4
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views6 pages

Practical File Format

This document is a practical file for Computer Science (083) for the term 2025-26, submitted by a student at Rosary Senior Secondary School. It includes a Python program that implements a stack using a list, detailing functions for pushing, popping, and displaying stack contents. The document also provides sample input and output demonstrating the program's functionality.

Uploaded by

teotiavansh4
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Practical File

Computer Science (083)


Term - I
(2025-26)

Submitted By
Name:
Roll Number:
Class & Section:

Rosary Senior Secondary School


Radio Colony, Kingsway Camp
Delhi – 110009
Page 1 of 6
INDEX

[Link] Practical Description Page No. Signature


1. WAP to swap/exchange the values of two variables.
2.
3.
4.
5.
6.
7.
8.
9.
10.

Page 2 of 6
Program No: 01

Write a Python program to implement a stack using list.

Source Code:
# Implementation of stack using list
st=[] #to create an empty list

def stkpush():
n=int(input("Enter a No. : "))
[Link](n)

def stkpop():
if st==[]:
print("Stack Underflow/Stack is Empty")
else:
print([Link]()," removed")

def display():
if st==[ ]:
print("Stack Underflow/Stack is empty")
else:
print("STACK CONTENTS: ")
L=len(st)-1
for i in range(L,-1,-1):
print(st[i])

while True:

Page 3 of 6
print('***STACK DEMONSTRATION***')
print('***1. PUSH***')
print('***2. POP***')
print('***3. DISPLAY***')
choice=int(input('Enter your choice (1-3) to continue and other than (1-3) to Exit'))
if choice==1:
stkpush()
elif choice==2:
stkpop()
elif choice==3:
display()
else:
print('Wrong choice')
break

Sample Input and Output:


***STACK DEMONSTRATION***
***1. PUSH***
***2. POP***
***3. DISPLAY***
Enter your choice (1-3) to continue and other than (1-3) to Exit3
Stack Underflow/Stack is empty
***STACK DEMONSTRATION***
***1. PUSH***
***2. POP***
***3. DISPLAY***
Enter your choice (1-3) to continue and other than (1-3) to Exit1
Enter a No. : 10

Page 4 of 6
***STACK DEMONSTRATION***
***1. PUSH***
***2. POP***
***3. DISPLAY***
Enter your choice (1-3) to continue and other than (1-3) to Exit1
Enter a No. : 20
***STACK DEMONSTRATION***
***1. PUSH***
***2. POP***
***3. DISPLAY***
Enter your choice (1-3) to continue and other than (1-3) to Exit3
STACK CONTENTS:
20
10
***STACK DEMONSTRATION***
***1. PUSH***
***2. POP***
***3. DISPLAY***
Enter your choice (1-3) to continue and other than (1-3) to Exit2
20 removed
***STACK DEMONSTRATION***
***1. PUSH***
***2. POP***
***3. DISPLAY***
Enter your choice (1-3) to continue and other than (1-3) to Exit2
10 removed
***STACK DEMONSTRATION***
***1. PUSH***

Page 5 of 6
***2. POP***
***3. DISPLAY***
Enter your choice (1-3) to continue and other than (1-3) to Exit2
Stack Underflow/Stack is Empty
***STACK DEMONSTRATION***
***1. PUSH***
***2. POP***
***3. DISPLAY***
Enter your choice (1-3) to continue and other than (1-3) to Exit3
Stack Underflow/Stack is empty
***STACK DEMONSTRATION***
***1. PUSH***
***2. POP***
***3. DISPLAY***
Enter your choice (1-3) to continue and other than (1-3) to Exit4
Wrong choice

Page 6 of 6

You might also like