Python Programs Full
Python Programs Full
Python Programs Full
1
def armstrong(n):
n1=n
s=0
while n>0:
r=n%10
s+=r**3
n//=10
if n1==s:
print('It is an armstrong number')
else:
print('It is not an armstrong number')
def multiplication(n,l):
for i in range (1,l+1):
print(n , "*" , i ," = ", n*i)
def prime(n):
if n==2:
print ("Is a prime No")
for i in range (2,n):
if n%i==0:
print("it is not a prime number")
break
else:
print("it is a prime number")
while True:
print("1.Reversing a number")
2
print('2.Checking a pallindrome')
print('3.Check whether an armstrong number')
print('4.Multiplication table of a number')
print('5.Check whether a prime no. or not')
ch=int(input("enter your choice:"))
n=int(input('enter the number:'))
if ch==1:
reverse(n)
elif ch==2:
palindrome(n)
elif ch==3:
armstrong(n)
elif ch==4:
l=int(input('enter the limit of multiplication:'))
multiplication(n,l)
elif ch==5:
prime(n)
else:
print('Invalid choice')
q=input('Do you want to exit? (Y/N)')
if q.upper()=='Y':
break
3
4
5
PYTHON PROGRAM 2
MENU DRIVEN PROGRAM WITH FUNCTIONS ON MUTABLE OBJECTS
Qn. Write an interactive menu driven program using functions which does the
following
Searches for an element in a list of values
Display the frequency of a particular element
Find the smallest and largest value among a list of values
Find the mean of a list of values
def search(L,e):
for i in range(len(L)):
if L[i]==e:
print('element not found at',i+1,'position')
break
else:
print('element not found')
def freq(L,e):
c=0
for i in L:
if i==e:
c+=1
print('occurance of the element',c)
def MAX_MIN(L):
l=s=L[0]
for i in L[1:]:
if i>1:
l=i
6
elif i<s:
s=i
print('maximum value is ',l)
print('minimum value is ',s)
def MEAN(L):
s=0
for i in L:
s+=i
m=s/len(L)
print('mean is ',m)
while True:
print('1.search for an element')
print('2.frequency of an element')
print('3.largest and smallest values')
print('4.mean of values')
ch=int(input('enter your choice : '))
if ch==1:
L=eval(input('enter the list '))
E=int(input('enter the element to be found '))
search(L,E)
elif ch==2:
L=eval(input('enter the list '))
E=int(input('enter the element to be counted '))
freq(L,E)
elif ch==3:
7
L=eval(input('enter the list '))
MAX_MIN(L)
elif ch==4:
L=eval(input('enter the list '))
MEAN(L)
else:
print('invalid choice')
q=input('do you want to exit? (Y/N):')
if q.upper()=='Y':
break
8
9
PYTHON PROGRAM 3
MENU DRIVEN PROGRAMS WITH FUNCTIONS ON IMMUTABLE
OBJECTS
Qn. Write a menu driven program that does the following :
Checks whether the string is a pallindrome or not
Counts the number of words in a string
Counts the number of uppercase alphabets, lowercase alphabets, digits
and special symbols
Converts uppercase to lowercase and lowercase to uppercase
def pallindrome(s):
i=0
l=len(s)
for j in range(-1,-l-1,-1):
if s[i]!=s[j]:
print('not a pallindrome')
break
i+=1
else:
print('is a pallindrome')
def countwords(s):
c=1
l=len(s)
for i in range(l):
if s[i].isspace():
c+=1
print('no. of words =',c)
10
def count(s):
uc=lc=d=sy=0
for i in range(len(s)):
if s[i].isalpha():
if s[i].isupper():
uc+=1
else:
lc+=1
elif s[i].isdigit():
d+=1
else:
sy+=1
print('no.of uppercase character = ',uc)
print('no. of lowercase character =',lc)
print('no. of digits =',d)
print('no. of special symbols =',sy)
def swapcase(s):
if s.isupper():
s=s.lower()
elif s.islower():
s=s.upper()
else:
s=s.swapcase()
print(s)
while True:
11
print('1.check whether a pallindrome')
print('2.count the no. of words')
print('3.count the no. of alphabets,digits and special symbols')
print('4.convert uppercase to lowercase and vice versa')
ch=int(input('enter your choice : '))
if ch==1:
s=input('enter the string : ')
pallindrome(s)
elif ch==2:
s=input('enter the string : ')
countwords(s)
elif ch==3:
s=input('enter the string : ')
count(s)
elif ch==4:
s=input('enter the string : ')
swapcase(s)
else:
break
12
13
PYTHON PROGRAM 4
MENU DRIVEN PROGRAM WITH RANDOM – LIST, TUPLE, DICTIONARY
Qn : Write a menu driven python program which does the following:
Create a list of 10 random numbers between 10 and 100
Create a tuple of 8 random numbers between 20 and 200
Create a dictionary of 7 key: values – random characters as key and ASCII
as its value
The program should repeat till the user presses Y/y
import random
def clist():
l=[]
for i in range(10):
n=random.randint(10,100)
l+=[n]
return l
def ctuple():
t=()
for i in range(8):
n=random.randint(20,200)
t+=(n,)
return t
def cdict():
d={}
for i in range (7):
a=random.randint(65,80)
b=chr(a)
14
d.update({b:a})
return d
while True:
print('1.Create a list of 10 random numbers between 10 and 100')
print('2.Create a tuple of 8 random numbers between 20 and 200')
print('3.Create a dictionary of 7 key: values – random characters as key and
ASCII as its value')
ch=int(input('enter the choice:'))
if ch==1:
l=clist()
print(l)
elif ch==2:
t=ctuple()
print(t)
elif ch==3:
d=cdict()
print(d)
else:
print('invalid choice')
break
15
16
PYTHON PROGRAM 5
MENU DRIVEN PROGRAM USING FUNCTIONS
Qn : Write a menu driven program which does the following:
Count the number of digits in a number
Find the product of odd digits in a number
Generate first 10 Mersenne Numbers
To display the Fibonacci series up to a limit
def count(n):
c=0
while n>0:
c+=1
n//=10
print('No. of Digits = ',c)
def product(n):
p=1
flag=0
while n>0:
r=n%10
if n%2!=0:
p*=r
flag=1
n//=10
if flag==0:
print('No odd digits in the number')
else:
print('Product of odd digits = ',p)
17
def mersenne():
print('Mersnne Numbers are :')
for i in range(1,11):
print(2**i-1,end='')
print()
def fibonacci(n):
n1,n2=0,1
print(n1,'\t',n2,end='\t')
for i in range(n-2):
n3=n1+n2
print(n3,end='\t')
n1,n2=n2,n3
print()
while True:
print('1.COUNT THE NO OF DIGITS')
print('2.PRODUCT OF ODD DIGITS ')
print('3.FIRST 10 MERSENNE NUMBERS')
print('4.FIBONACCI SERIES')
print('5.EXIT')
ch=int(input('Enter ur choice:'))
if ch==1:
n=int(input('Enter the number:'))
count(n)
elif ch==2:
n=int(input('Enter the number:'))
18
product(n)
elif ch==3:
mersenne()
elif ch==4:
n=int(input('Enter the limit:'))
fibonacci(n)
else:
print('INVALID CHOICE')
break
PYTHON PROGRAM 6
19
TEXT FILE – CREATE & DISPLAY
Qn: A text file records.txt contains information of a student (roll number,
name, marks). Write a menu driven program which does the following :
Add records to the file
Display the records
Quit
fname='C:\\Users\\User\\Desktop\\records.txt'
def create():
f=open(fname,'w')
s=[]
while True:
rno=input('Roll No : ')
n=input('Name : ')
m=input('Marks : ')
s.append(rno+','+n+','+m+'\n')
q=input('Do you want to add more records?(Y/N): ')
if q.upper()=='N':
break
f.writelines(s)
f.close()
def display():
f=open(fname)
r=f.readlines()
for i in r:
print(i)
f.close()
20
ch=0
while ch!=3:
print('1.Add records')
print('2.Display records')
print('3.Quit')
ch=int(input('Enter your choice : '))
if ch==1:
create()
elif ch==2:
display()
elif ch==3:
break
else:
print('Invalid choice')
PYTHON PROGRAM 7
TEXT FILE – CREATE, DISPLAY & DUPLICATE
21
Qn: Write an interactive menu driven program which does the following:
Create a text file school.txt with admission number, name and class of a
particular student
Display the file content
Create another file Uschool.txt with the details in uppercase
Exit
fname1='C:\\Users\\User\\Desktop\\School.txt'
fname2='C:\\Users\\User\\Desktop\\USchool.txt'
def create():
f=open(fname1,'a')
s=[]
while True:
admno=input('ADMISSION NO. : ')
n=input('NAME : ')
Class=input('CLASS : ')
s.append(admno+','+n+','+Class+'\n')
q=input('Do you want to add more records(Y/N): ')
if q.upper()=='N':
break
f.writelines(s)
f.close()
def display():
f=open(fname1)
r=f.read()
print(r)
f.close()
22
def Upper():
f=open(fname1)
f1=open(fname2,'w')
r=f.read()
f1.write(r.upper())
f.close()
f1.close()
def show():
f1=open(fname1)
f2=open(fname2)
r1=f1.read()
print('Displaying original file')
print(r1)
r2=f2.read()
print('Displaying duplicate file in uppercase')
print(r2)
f1.close()
f2.close()
ch=0
while ch!=5:
print('1.Create Records')
print('2.Display Original Files')
print('3.Create Duplicate File In Uppercase')
print('4.Display Both Files')
print('5.Quit')
23
ch=int(input('enter your choice : '))
if ch==1:
create()
elif ch==2:
display()
elif ch==3:
Upper()
elif ch==4:
show()
elif ch==5:
break
else:
print('Invalid Choice')
24
25
PYTHON PROGRAM 8
TEXT FILE – ADD, DISPLAY AND SEARCH
Qn. A text file records.txt contains information of a student such as roll number,
name and marks. Write a menu driven program which does the following :
Add the records to the file
Display the records
Search for a particular record based on the roll number
Quit
fname='C:\\Users\\User\\Desktop\\records.txt'
def create():
f=open(fname,'a')
s=[]
while True:
rno=input('Roll number : ')
name=input('Name : ')
m=input('Marks : ')
s.append(rno+','+name+','+m+'\n')
q=input('More records?(Y/N)')
if q.upper()=='N':
break
f.writelines(s)
f.close()
def display():
f=open(fname)
r=f.read()
print(r)
26
f.close()
def search():
f=open(fname)
no=int(input('enter the number'))
flag=0
n=f.readline()
for n in f:
i=0
roll_no=''
while True:
if n[i]==',':
break
if n[i]>='0' and n[i]<='9':
roll_no+=n[i]
i+=1
roll_no=int(roll_no)
if roll_no==no:
print(n)
flag=1
break
if flag==0:
print('No Such Records')
f.close()
while True:
print('1.Create records')
27
print('2.Display records')
print('3.Searh for a record using roll no')
print('4.Quit')
ch=int(input('Enter your Choice:'))
if ch==1:
create()
elif ch==2:
display()
elif ch==3:
search()
elif ch==4:
break
else:
print('Invalid choice')
28
29
PYTHON PROGRAM 9
BINARY FILE – ADD,DISPLAY AND SEARCH
Qn: Write a program which creates a file book.dat which contains book number,
book name, author name and price. The program should do the following
Display the content of the file
Add records to the end of the file
Search for records based on book number
Quit
import pickle as p
n='C:\\Users\\User\\Desktop\\book.dat'
def create():
f=open(n,'wb')
while True:
b=[]
bno=int(input('Book number:'))
name=input('Book name:')
aname=input('Author name:')
price=float(input('Price:'))
b=[bno,name,aname,price]
p.dump(b,f)
q=input('More records? (Y/N):')
if q.upper()=='N':
break
f.close()
def addata():
f=open(n,'ab')
while True:
30
b=[]
bno=int(input('Book number:'))
name=input('Book name:')
aname=input('Author name:')
price=float(input('Price:'))
b=[bno,name,aname,price]
p.dump(b,f)
q=input('More records? (Y/N):')
if q.upper()=='N':
break
f.close()
def display():
f=open(n,'rb')
try:
while True:
b=p.load(f)
print(b)
except:
pass
f.close()
def search():
f=open(n,'rb')
no=int(input('Book no:'))
flag=0
try:
while True:
b=p.load(f)
31
if b[0]==no:
print(b)
flag=1
except:
pass
if flag==0:
print('No such records found')
f.close()
create()
while True:
print('1.Display the records')
print('2.Add records')
print('3.Seach for particular record')
print('4.Exit')
ch=int(input('enter your choice:'))
if ch==1:
display()
elif ch==2:
addata()
elif ch==3:
search()
elif ch==4:
break
else:
print('Invalid choice')
32
33
PYTHON PROGRAM 10
BINARY FILE – ADD, DISPLAY, APPEND AND SEARCH
Qn: Create a binary file car.dat which contains the following information car
number, car type, company name, mileage, price. Write a menu driven program
which does the following
Display the records
Appends the records
Search the records based on car number
Search the records based on car type
Search the records whose company name is Toyota
Search the records whose mileage is in the range of 10 to 20
Search the records whose rate is greater then 100
Quit
fname='C:\\Users\\User\\Desktop\\car.dat'
import pickle
def create():
f=open(fname,'wb')
while True:
c=[]
cno=int(input('Enter the Car number'))
c.append(cno)
cartype=input('Enter the Car Type')
c.append(cartype)
company=input('Enter the Company name')
c.append(company)
m=int(input('Enter the Mileage'))
c.append(m)
rate=float(input('Enter the rate '))
c.append(rate)
34
pickle.dump(c,f)
ch=input('Do u want to continue(Y/N)?')
if ch.upper()=='N':
break
f.close()
def display():
f1=open(fname,'rb')
try:
while True:
c=[]
c=pickle.load(f1)
print(c)
except:
pass
f1.close()
def append():
f2=open(fname,'ab')
while True:
c=[]
cno=int(input('Enter the Car number'))
c.append(cno)
cartype=input('Enter the Car Type')
c.append(cartype)
company=input('Enter the Company name')
c.append(company)
m=int(input('Enter the Mileage'))
c.append(m)
35
rate=float(input('Enter the rate '))
c.append(rate)
pickle.dump(c,f2)
ch=input('Do u want to continue(Y/N)?')
if ch.upper()=='N':
break
f2.close()
def searchno():
f3=open(fname,'rb')
no=int(input('Enter the carno which has to be searched'))
if not f3:
print('File does not exist')
else:
try:
REC=[]
while True:
c=[]
c=pickle.load(f3)
REC.append(c)
except EOFError:
pass
found=0
for x in REC:
if no==x[0]:
print(x)
found=1
if found==0:
36
print('Record Does not exist')
f3.close()
def searchcartype():
f4=open(fname,'rb')
ct=input('Enter the car type which has to be searched')
if not f4:
print('File does not exist')
else:
try:
REC=[]
while True:
c=[]
c=pickle.load(f4)
REC.append(c)
except EOFError:
pass
found=0
for x in REC:
if ct==x[1]:
print(x)
found=1
if found==0:
print('Record Does not exist')
f4.close()
def searchcompany():
f4=open(fname,'rb')
if not f4:
37
print('File does not exist')
else:
try:
REC=[]
while True:
c=[]
c=pickle.load(f4)
REC.append(c)
except EOFError:
pass
found=0
for x in REC:
if x[2]=='TOYOTA':
print(x)
found=1
if found==0:
print('Record Does not exist')
f4.close()
def searchmileage():
f3=open(fname,'rb')
found=0
if not f3:
print('File does not exist')
else:
try:
while True:
c=[]
38
c=pickle.load(f3)
if c[3]>=10 and c[3]<=20:
print(c)
found=1
except EOFError:
pass
if found==0:
print('No Such Records')
f3.close()
def searchrate():
f3=open(fname,'rb')
found=0
if not f3:
print('File does not exist')
else:
try:
while True:
c=[]
c=pickle.load(f3)
if c[4]>1000 :
print(c)
found=1
except EOFError:
pass
if found==0:
print('No Such Records')
f3.close()
39
print('Details of car')
create()
ch=0
while ch!=8:
print('1.DISPLAY THE CONTENT\n2.APPEND RECORDS\n3.SEARCH FOR
A RECORD BASED ON CAR NO\n4.SEARCH FOR A RECORD BASED ON
CARTYPRE\n5..SEARCH FOR A RECORD WHOSE COMAPNY NAME IS
TOYOTA\n6.SEARCH FOR ARECORD WHOSE MILEAGE IS IN THE
RANGE OF 100 AND 200\n7.SEARCH FOR A RECORD WHOSE RATE IS
GREATER THAN 100\n8.QUIT')
ch=int(input('ENTER YOUR CHOICE'))
if ch==1:
display()
elif ch==2:
append()
elif ch==3:
searchno()
elif ch==4:
searchcartype()
elif ch==5:
searchcompany()
elif ch==6:
searchmileage()
elif ch==7:
searchrate()
else:
break
40
41
42
PYTHON PROGRAM 11
BINARY FILE – ADD, DISPLAY, SEARCH, MODIFY, AND DELETE
Qn: A binary file hospital.dat contains the following details of patients Admno.,
Name, Patient type, Deptname, Doctor Name, Amount.
Write a menu driven program which does the following Insert Records
Display Records
Search for all patients based on Admno
Search for all patients who are under a particular department
Search for all patients who are either In – patient or Out-patient
Modify a particular record based on the admno
Delete a record
fname='C:\\Users\\User\\Desktop\\hospital.dat'
fname1='C:\\Users\\User\\Desktop\\temp.dat'
import pickle as p
import os
def create():
f=open(fname,'ab')
while True:
a=int(input('ADMNO:'))
n=input('NAME:')
pt=input('Patient Type(I/O)')
d=input("DEPARTMENT")
dn=input('DOC NAME:')
amt=int(input("BILL AMT:"))
D={'ADMNO':a,'NAME':n,'PTYPE':pt,'DEPT':d,'DOC NAME':dn,
'AMOUNT':amt}
p.dump(D,f)
ch=input('MORE RECORDS?')
43
if ch.upper()=='N':
break
f.close()
def display():
f=open(fname,'rb')
try:
while True:
D=p.load(f)
print(D)
except:
pass
def searchad():
ad=int(input('Enter the ADMNO:'))
flag=0
f=open(fname,'rb')
try:
while True:
D=p.load(f)
if D['ADMNO']==ad:
print(D)
flag=1
except:
pass
if flag==0:
print('Record does not exist')
def searchdept():
d=input('Enter the Dept name:')
44
flag=0
f=open(fname,'rb')
try:
while True:
D=p.load(f)
if D['DEPT']==d:
print(D)
flag=1
except:
pass
if flag==0:
print('Record does not exist')
def searchtype():
type=input('PATIENT TYPE(I/O)')
flag=0
f=open(fname,'rb')
try:
while True:
D=p.load(f)
if D['PTYPE'].upper()==type.upper():
print(D)
flag=1
except:
pass
if flag==0:
print('Record does not exist')
def modify():
45
f1=open(fname,'rb')
f2=open(fname1,'wb')
no=int(input('Enter the admno:'))
flag=0
try:
while True:
D=p.load(f1)
if D['ADMNO']==no:
a=int(input('ADMNO:'))
n=input('NAME:')
pt=input('Patient Type(I/O)')
d=input("DEPARTMENT")
dn=input('DOC NAME:')
amt=int(input("BILL AMT:"))
D={'ADMNO':a,'NAME':n,'PTYPE':pt,'DEPT':d,'DOC NAME':dn,
'AMOUNT':amt}
flag=1
p.dump(D,f2)
except:
pass
if flag==0:
print('No such records')
f1.close()
f2.close()
os.remove('hospital.dat')
os.rename('temp.dat','hospital.dat')
def Delete():
46
f1=open(fname,'rb')
f2=open(fname1,'wb')
no=int(input('Enter the admno:'))
flag=0
try:
while True:
D=p.load(f1)
if D['ADMNO']!=no:
flag=1
p.dump(D,f2)
except:
pass
if flag==0:
print('No such records')
f1.close()
f2.close()
os.remove('hospital.dat')
os.rename('temp.dat','hospital.dat')
create()
while True:
print('1.Diplay Records')
print('2.Search Rcords Based On Admno')
print('3.Search Based on Dept')
print('4.Search Based on Patient Type')
print('5.Modify Based on Admno')
print('6.Delete Based on admno')
print('7.Quit')
47
c=int(input('CHOICE:'))
if c==1:
display()
elif c==2:
searchad()
elif c==3:
searchdept()
elif c==4:
searchtype()
elif c==5:
modify()
elif c==6:
Delete()
else:
break
48
49
PYTHON PROGRAM 12
CSV FILE – ADD, DISPLAY, AND SEARCH
Qn. Write a menu driven program which creates a CSV file ‘product.csv’ which
contains product ID, product name, company name, dealer name, Quantity, and
price. The menu should have the following options:
Add new products to the file
Display all product details
Search for all products whose price is >150
Search for all products whose Quantity is <100
Search for all products manufactured by a particular company
Exit
import csv
fname='product.csv'
def create():
f=open(fname,'a',newline='')
r=csv.writer(f)
while True:
pid=input('Product ID:')
pname=input('Product Name:')
cname=input('Company Name:')
dname=input('Dealer name:')
qty=input('Quantity:')
price=input('Price:')
p=[pid,pname,cname,dname,qty,price]
r.writerow(p)
ch=input('More records (Y/N):')
if ch.upper()=='N':
break
50
f.close()
def display():
f=open(fname,'r')
r=csv.reader(f)
for i in r:
print(i)
f.close()
def psearch():
f=open(fname,'r')
flag=0
r=csv.reader(f)
for i in r:
if int(i[5])>150:
print(i)
flag=1
if flag==0:
print('Record not found')
f.close()
def qsearch():
f=open(fname,'r')
flag=0
r=csv.reader(f)
for i in r:
if int(i[4])<100:
print(i)
flag=1
if flag==0:
51
print('Record not found')
f.close()
def csearch():
f=open(fname,'r')
flag=0
r=csv.reader(f)
c=input('Company name:')
for i in r:
if i[2].upper()==c.upper():
print(i)
flag=1
if flag==0:
print('Record not found')
f.close()
create()
while True:
print('1.Add new products')
print('2.Display all products')
print('3.Search for products;price>150')
print('4.Search for products;qty<100')
print('5.Search for products manufactured by acompany')
print('6.Exit')
c=int(input('choice:'))
if c==1:
create()
elif c==2:
display()
52
elif c==3:
psearch()
elif c==4:
qsearch()
elif c==5:
csearch()
elif c==6:
break
else:
print('Invalid choice')
53
54
PYTHON PROGRAM 13
STACK OPERATIONS
Qn: Write a menu driven program which implements the concept of a
stack and does the following operations
Push an element
Pop an element
Peek an element
Display the stack
Exit
def insert(L):
while True:
e=eval(input('enter the element:'))
L.append(e)
c=input('More values? (Y/N):')
if c.upper()=='N':
break
def delete(L):
while True:
if len(L)==0:
print('Underflow')
else:
print('Deleted value is',L.pop())
c=input('More values? (Y/N):')
if c.upper()=='N':
break
def peek(L):
if len(L)==0:
print('Empty stack')
55
else:
print(L[-1])
def Display(L):
l=len(L)
if l==0:
print('Empty stack')
else:
for i in range(l-1,-1,-1):
print(L[i])
L=[]
while True:
print('1.Push an element')
print('2.Pop an element')
print('3.Peek an element')
print('4.Display the stack')
print('5.Exit')
c=int(input('choice:'))
if c==1:
insert(L)
elif c==2:
delete(L)
elif c==3:
peek(L)
elif c==4:
Display(L)
elif c==5:
break
56
else:
print('Invalid choice')
PYTHON PROGRAM 14
STACK OPERATIONS
57
Qn: Write a menu driven program which implements the concept of a stack and
stores employee details such as Employee Number, Employee name,
Department, Salary.
The program should have the following
Push() → To insert records
Pop() → To delete records
Peek() → To peek a record
Show() → To display the content of the stack
Exit
def Push(L):
while True:
Eno=int(input('Employee number:'))
Ename=input('Employee name:')
Dept=input('Department:')
Salary=float(input('Salary:'))
r=[Eno,Ename,Dept,Salary]
L.append(r)
c=input('More records? (Y/N):')
if c.upper()=='N':break
def Pop(L):
while True:
if len(L)==0:
print('Underflow')
else:
print('Deleted record is',L.pop())
c=input('Delete more records? (Y/N):')
if c.upper()=='N':
break
58
def Peek(L):
if len(L)==0:
print('Empty stack')
else:
print(L[-1])
def Show(L):
l=len(L)
if l==0:
print('Empty stack')
else:
for i in range(l-1,-1,-1):
print(L[i])
L=[]
while True:
print('1.Insert records')
print('2.Delete records')
print('3.Peek the records')
print('4.Display the content of the stack')
print('5.Exit')
c=int(input('choice:'))
if c==1:
Push(L)
elif c==2:
Pop(L)
elif c==3:
Peek(L)
elif c==4:
59
Show(L)
elif c==5:
break
else:
print('Invalid choice')
60