0% found this document useful (0 votes)
17 views72 pages

PYTHON Programs

Uploaded by

nithishkumar3845
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)
17 views72 pages

PYTHON Programs

Uploaded by

nithishkumar3845
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
You are on page 1/ 72

S.

NO NAME OF PROGRAM PAGE DATE OF REMARKS


NO COMPLITION
1. write a fibonacci program using function for n terms

2. write a program to find factorial of a given no

3. write a program to find the maximum of 3 nos

4. write a program to calculate sum of n natural no

5. write a program to take a list and find sum of odd and


even numbers

6. write a program to find a no is pallindrome or not

7. write a program to find sum of any two given numbers by user


using function

8. write a program to show the effect in output obtained when


use global keyword

9. write a program to show the use of default variable in a


function
10. write a program to show the difference in the output produced
rather than the expected output when we supply a mutable
data type to the function
11. write a program to display a list odd number present in
another list
12. write a program to generate a user defined function which
returns a list of indices of non-zero elements present in
another list which is given as an argument to function

13. write a program to add each element, present in a user


specified list by some number which is also user specified
14. write a program to check if a character (case sensitive) is
present in a string or not and return the no of occurrences of
that character in that string
15. write a program to generate a user defined function which
returns a list of indices of non-zero elements present in
another list which is given as an argument to function
16. Write a program to read the content of file and display the
total number of consonants, upper case, vowels and lowercase
characters
17. Write a program to read and display content line by line with
each word separated by ‘#’

18. Write a program to read the content of a file line by line write
it to another file except for the lines which contain the letter
‘a’ letter in it
19. Write a Program to store student’s details like admission
number, roll number, name and percentage in a dictionary
and display information on the basis of admission number.

20. Write a program to count the number of vowels, consonants,


digits and special characters in a string
21. Write a program to add marks and calculate the grade of a
student
22. Write a program to read a text file line by line and display
each word separated by '#
23. write a program to find the number of occurrences of a word
which is specified by the user in a text file
24. write a program to find the total number of words present in a
textfile
25. write a program to write some sentences into a text file till the
user wants to write using write() function
26. write a program to the name, roll no and marks of students
specified by user into binary file
27. write a program to get the records from the binary file
student
28. write a program to retrieve the records of those students
whose roll no are present in the list of roll numbers specified
by the user
29. write a program to update the name of the student in
“student.dat”, by the name specified the user who is having
the roll number which is given by the user

30. write a program to create a csv file and add records to it

31. write a program to get item details from the user in the
format (code, description and price) for multiple items from
the user and create a csv file by writing all the item details in
one go

32. STACK IMPLEMENTATION

33. Write a Python & MySQL connectivity program to solve the


queries.
a. Display students' records from the table based on gender as
female.
b. Display name and age of students whose age is 23 and
above.
c. Display details of all the students whose name starts with
'S'. TABLE: STUDENT
34. Write a Python & MySQL connectivity program to solve the
queries.
a. To search records from the following STUDENT table
based on nonmedical students of class 12.
b. List the details of those students who are in class 12 sorted
by name.
c. To list name of female students who are in commerce
stream.
35. Write a Python & MySQL connectivity program to generate
queries.
a. List the name of students who are in class 12 sorted by
average marks. b. Search minimum of average mark from the
above table where average marks<75.
c. Search following STUDENT table to delete all the records
whose Avgmark is less than 80.
36. MSQL SINGLE TABLE TYPE
Table-1
37. MSQL SINGLE TABLE TYPE
Table-2
38. MSQL SINGLE TABLE TYPE
Table-3
39. MSQL DOUBLE TABLE TYPE
NO-1
40. MSQL DOUBLE TABLE TYPE
NO-2
41. MSQL DOUBLE TABLE TYPE
NO-3
PYTHON PROGRAM – 1
AIM:- write a fibonacci program using function for n terms

CODE:-

def fibo(n):

a=0

b=1

print(a)

print(b)

for i in range (2,n):

c=a+b

print(c)

a=b

b=c

n=int(input("enter no of terms "))

fibo(n)
OUTPUT:-

enter no of terms : 5

3
PYTHON PROGRAM – 2
AIM:- write a program for factorial of a given no

CODE:-

def fac(n):

f=1

for i in range (1,n+1):

f=f*i

return(f)

OUTPUT:-

enter no 3

6
PYTHON PROGRAM - 3
AIM:- write a program to find the maximum of 3 nos

CODE:-

a=int(input("enter no "))

b=int(input("enter no"))

c=int(input("enter no"))

def max():

if a>b and a>c:

print("max is", a)

elif b>a and b>c:

print("max is",b)

else:

print("max is",c)

max()

OUTPUT:-

enter number 12

enter number 14

enter number 49

49 is the largest number


PYTHON PROGRAM - 4
AIM:- write a program to calculate sum of n natural no

CODE:-

n=int(input("enter n"))

def sum(n):

s=1

for i in range(2,n+1):

s=s+i

print(s)

sum(n)

OUTPUT:-

enter n 6

21
PYTHON PROGRAM – 5

AIM:- write a program to take a list and find sum of odd


and even numbers

CODE:-

l=eval(input("enter a list"))

def eosum():

e=0

o=0

for i in l:

if i%2==0:

e=e+i

else:

o=o+i

return o,e

eosum()

print(eosum())
OUTPUT:-

enter a list [1,2,3,4,5,6]

(9, 12)

PYTHON PROGRAM - 6
AIM:- write a program to find a no is pallindrome or not

CODE:-

n=int(input("enter no"))

def pal():

global n

while n!=0:

s=0

r=n%10

s=s*10+r

n=n//10

if s==n:

print("it is pallindrome")

else:

print ("it is not pallindrome")

pal()
OUTPUT:-

enter no 563

it is not pallindrome

PYTHON PROGRAM - 7

AIM:- write a program to find sum of any two given


numbers by function

CODE:-

def sum(x,y):

z=x+y

return z

a=int(input(“enter the number”))

b=int(input(“enter the number”))

s=sum(a,b)

print(“sum of the numbers”,a,’and’,b;”is”,s)

OUTPUT:-
enter the number 45

enter the number 55

sum of the numbers 45 and 55 is 100

PYTHON PROGRAM - 8
AIM:- write a program to show the effect in output
obtained when use global keyword
CODE:-
print("before using global keyword")
def fun1(): a=10
return a
a=5
print("value of a is",a)
print("after evaluated by function value of a is",fun1())
print("value of a (outside function body after evaluation) is",a)
print("after using global keyword")
def fun2():
global a a=10
return a
a=5
print("value of a is",a)
print("after evaluated by function value of a is",fun2())
print("value of a (outside function body after evaluation) is",a)
OUTPUT:-
before using global keyword
value of a is 5
after evaluated by function value of a is 10
value of a (outside function body after evaluation) is 5 after using
global keyword
value of a is 5
after evaluated by function value of a is 10
value of a (outside function body after evaluation) is 10

PYTHON PROGRAM - 9

AIM:- write a program to show the use of default


variable in a function

CODE:-

def disp(x=2,y=3):

x=x+y y+=2

print("value of x and y is",x, "and",y)

print("when no value is supplied for x and y") disp()

print("when both the inputs are supplied") disp(5,1)


print("when only one input is supplied") disp(9)

OUTPUT:-

when no value is supplied for x and y

value of x and y is 5 and 5

when both the inputs are supplied

value of x and y is 6 and 3 when only one input is supplied

value of x and y is 12 and 5

PYTHON PROGRAM - 10
AIM:- write a program To show the difference in the
output produced rather than the expected output when
we supply a mutable data type to the function

CODE:-

def check(a):

for i in range(len(a)): a[i]=a[i]+5

return a

b=[1,2,3,4]

c=check(b)
print("the list after modification by function is",c)

print("the final list (when provoked outside the function body)


is"‚c)

print('''the changes are reflected because the input given to

function was mutable type which is following the mechanism of


call by reference''')

OUTPUT:-

the list after modification by function is [6, 7, 8, 9]


the final list (when provoked outside the function body) is [6, 7, 8, 9]
the changes are reflected because the input given to
function was mutable type which is following the mechanism of
call by reference

PYTHON PROGRAM - 11
AIM:- write a program to display a list odd number
present in another list

CODE:-

def odd(k): |1=[]

length= len(k)

for i in range(length):

if k[i]%2!=0:
11.append(k[i])

print("the required list with odd numbers only from input is",l1)
list=eval(input("enter a list"))

odd(list)

OUTPUT:-

enter a list[1,2,3,4,5,12,31,45]

the required list with odd numbers only from input is [1, 3, 5, 31,
45]

enter a list[35,87,66,45,88]

the required list with odd numbers only from input is [35, 87, 45]

PYTHON PROGRAM - 12
AIM:- write a program to generate a user defined
function which returns a list of indices of non-zero
elements present in another list which is given as an
argument to function

CODE:-

def non_zero(1): length=len(1) |1=[]


for i in range(length):

if I[i]!=0:

11.append(i)

print("the required list of indices of non zero element of given list


is",11) k=eval(input("enter a list"))

non_zero(k)

OUTPUT:-

enter a list [0,0,0,0,3,4,5]

the required list of indices of non zero element of given list is


[4, 5, 6]

enter a list [1,0,34,0,56,3,4,0,6,0]

the required list of indices of non zero element of given list is


[0, 2, 4, 5, 6, 8]
PYTHON PROGRAM - 13

AIM:- write a program to add each element, present in


a user specified list by some number which is also user
specified

CODE:-

def list(k,P): length=len(k)

for i in range(length): k[i]=k[i]+P

print("updated list is ",k)

K=eval(input("enter a list"))

P=int(input("enter the number which is to be added to each


element"))

list(K,P)

OUTPUT:-

enter a list [1,2,3,4,5,6,7,8,9,10]

enter the number which is to be added to each element 10

updated list is [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]

enter a list [44,78,99,100]

enter the number which is to be added to each element 100


updated list is [144, 178, 199, 200]

PYTHON PROGRAM - 14
AIM:- write a program to check if a character (case
sensitive) is present in a string or not and return the no
of occurrences of that character in that string

CODE:-

def search(1,p): count=0

length= len(1)

for i in range(length):

if I[i]==p:

count += 1

print("the character",o,"is present and it's count is",count)

if count==0:

print("not found")

k=input("enter a string")

o=input("enter a character")

search(k,o)

OUTPUT:-

enter a string PYTHON IS FUN

enter a character N

the character N is present and it's count is 2


enter a string ATOMIC ENERGY CENTRAL SCHOOL
enter a character E

the character E is present and it's count is 3

PYTHON PROGRAM - 15
AIM:- write a program to generate a user defined
function which returns a list of indices of non-zero
elements present in another list which is given as an
argument to function

CODE:-

def non_zero(1): length=len(1) |1=[]

for i in range(length):

if I[i]!=0:

11.append(i)

print("the required list of indices of non zero element of given list


is",11) k=eval(input("enter a list"))

non_zero(k)

OUTPUT:-

enter a list [0,0,0,0,3,4,5]

the required list of indices of non zero element of given list is


[4, 5, 6]

enter a list [1,0,34,0,56,3,4,0,6,0]


the required list of indices of non zero element of given list is
[0, 2, 4, 5, 6, 8]

PYTHON PROGRAM - 16
AIM:- Program to read the content of file and display
the total number of consonants, upper case, vowels
and lowercase characters.
CODE:-
f = open("file1.txt")
v=0
c=0
u=0
l=0
o=0
data = f.read()
vowels=['a','e','i','o','u']
for ch in data:
if ch.isalpha():
if ch.lower() in vowels:
v+=1
else:
c+=1
if ch.isupper():
u+=1
elif ch.islower():
l+=1
elif ch!=' ' and ch!='\n':
o+=1
print("Total Vowels in file :",v)
print("Total Consonants in file :",c)
print("Total Capital letters in file :",u)
print("Total Small letters in file :",l)
print("Total Other than letters :",o)
f.close()

OUTPUT:-
Total Vowels in file : 16
Total Consonants in file : 30
Total Capital letters in file : 3
Total Small letters in file : 43
Total Other than letters : 0

PYTHON PROGRAM - 17
AIM:-program to read and display content line by line
with each word separated by ‘#’

CODE:-

f=open("file1.txt")
for line in f:
words=line.split()
for w in words:
print(w+'#',end="")
print()
f.close()

OUTPUT:-

India#is#my# country#

I#love#python#
Python#learning#is#fun#

PYTHON PROGRAM - 18

AIM:-program to read the content of a file line by line


write it to another file except for the lines which
contain the letter ‘a’ letter in it

CODE:-
f1 = open("file1.txt")
f2 = open("file2copy.txt","w")
for line in f1:
if 'a' not in line:
f2.write(line)
print("## File Copied Successfully! ##")
f1.close()
f2.close()

OUTPUT:-
## File Copied Successfully! ##

>>>

PYTHON PROGRAM - 19
AIM:- Program to store student’s details like
admission number, roll number, name and
percentage in a dictionary and display
information on the basis of admission number.

CODE:-

record = dict ()
i=1
n= int (input ("How many records u want to enter: "))
while(i<=n):
Adm = input("Enter Admission number: ")
roll = input("Enter Roll Number: ")
name = input("Enter Name :")
perc = float(input("Enter Percentage : "))
t = (roll,name, perc)
record[Adm] = t
i=i+1
Nkey = record.keys()
for i in Nkey:
print("\nAdmno- ", i, " :")
OUTPUT:-

How many records u want to enter : 2

Enter Admission number: 101

Enter Roll Number: 34

Enter Name :Ganesh

Enter Percentage : 78

Enter Admission number: 102

Enter Roll Number: 29

Enter Name : Ritish

Enter Percentage : 79
Admno- 101 :

Roll No Name Percentage

34 Ganesh 78.0

Admno- 102 :

Roll No Name Percentage

29 Ritish 79.0

PYTHON PROGRAM - 20
AIM:- Python program to count the number of vowels,
consonants, digits and special characters in a string

CODE:-

str = input(“Enter the string : “)


vowels = 0
digits = 0
consonants = 0
spaces = 0
symbols = 0
str = str.lower()
for i in range(0, len(str)):
if(str[i] == ‘a’or str[i] == ‘e’ or str[i] == ‘i’
or str[i] == ‘o’ or str[i] == ‘u’):
vowels = vowels + 1
elif((str[i] >= ‘a’and str[i] <= ‘z’)):
consonants = consonants + 1
elif( str[i] >= ‘0’ and str[i] <= ‘9’):
digits = digits + 1
elif (str[i] ==’ ‘):
spaces = spaces + 1
else:
symbols = symbols + 1

print(“Vowels: “, vowels);
print(“Consonants: “, consonants);
print(“Digits: “, digits);
print(“White spaces: “, spaces);
print(“Symbols : “, symbols);

OUTPUT:-

Enter the string: 123 hello world $%&45

Vowels: 3

Consonants: 7

Digits: 5
White spaces: 3

Symbols: 3
PYTHON PROGRAM - 21
AIM:- Write a Program to add marks and calculate the
grade of a student

CODE:-
total=int(input("Enter the maximum mark of a subject: "))
sub1=int(input("Enter marks of the first subject: "))
sub2=int(input("Enter marks of the second subject: "))
sub3=int(input("Enter marks of the third subject: "))
sub4=int(input("Enter marks of the fourth subject: "))
sub5=int(input("Enter marks of the fifth subject: "))
average=(sub1+sub2+sub3+sub4+sub5)/5
print("Average is ",average)
percentage=(average/total)*100
print("According to the percentage, ")
if percentage >= 90:
print("Grade: A")
elif percentage >= 80 and percentage < 90:
print("Grade: B")
elif percentage >= 70 and percentage < 80:
print("Grade: C")
elif percentage >= 60 and percentage < 70:
print("Grade: D")
else:
print("Grade: E")

OUTPUT:-

Enter the maximum mark of a subject: 10

Enter marks of the first subject: 8

Enter marks of the second subject: 7

Enter marks of the third subject: 9

Enter marks of the fourth subject: 6

Enter marks of the fifth subject: 8

Average is 7.6

According to the percentage,

Grade: C
PYTHON PROGRAM - 22

AIM:- Write a program to read a text file line by line and


display each word separated by '#

CODE:-

filein = open("Mydoc.txt",'r')

for line in filein:

word= line .split()

for w in word:

print(w + '#',end ='')

print()

filein.close()

OUTPUT:-

Text in file:

hello how are you?

python is case-sensitive language.


Output in python shell:

hello#how#are#you?#python#is#case-sensitive#language.#

PYTHON PROGRAM - 23

AIM:- write a program to find the number of occurrences


of a word which is specified by the user in a text file

CODE:-

def count(w)

c=O

open myfile.txt", r")

t=f.read()

s=t.split()

for i in

if

print("the number of occurrences of word", w, "is", c)

f.close()

w=input("enter the word to be counted")


count(w)

OUTPUT:-

enter the word to be counted as

the number of occurrences of word as is 5

PYTHON PROGRAM - 24
AIM:- write a program to find the total number of words
present in a textfile

CODE:-

def count()

c=O

f=open (“myfile.txt", r")

t=f.read()

s=t.split()

for i in

print("the number of words present in the text file is",c)

f.close()

OUTPUT:-
the number of words present in the text file is 34

PYTHON PROGRAM - 25
AIM:- write a program to write some sentences into a
text file till the user wants to write using write()
function

CODE:-

def write()

f=open (“myfile.txt",”w”)

ans= "yes"

while ans=="yes":

d=input("enter the string to be written")

f.write(d)

ans=input("enter yes or no")

f.close()
write()

OUTPUT:-

enter the string to be written what is a black hole

enter yes or no yes

enter the string to be written it is entity which is formed due to


the death of massive star

enter yes or no yes

enter the string to be written it has a singularity which is a point


with infinite density and zero
volume

enter yes or no no

TEXT :-

what is a black hole it is entity which is formed due to the death of


massive star it has a singularity which is a point with infinite density
and zero volume
PYTHON PROGRAM - 26

AIM:- write a program to the name, roll no and marks of


students specified by user into binary file

CODE:-

import pickle

student={}

file=open("student.dat","wb")
answer="Y"

while answer=="Y":

roll_no=int(input("enter roll no of students"))

name=input("enter name")

marks=int(input("enter marks"))

student["NAME"]=name

student["ROLL_NO"]=roll_no

student["MARK"]=marks

pickle.dump(student, file)

answer=input("enter Y or N")

file.close()

OUTPUT:-

enter roll no of students 1

enter name MOHAN

enter marks 99

enter Y or N Y

enter roll no of students 2

enter name SOHAN

enter marks 89

enter Y or N Y
enter roll no of students 3

enter name ROHAN

enter marks 100

enter Y or N Y

enter roll no of students 4

enter name GUGAN

enter marks 55

enter Y or N N

RESULT :-

(ŒNAME"MOHAN"ŒROLL_NO"KŒMARK❞Kcu. €•)

}" (ŒNAME"ŒSOHAN"ŒROLL_NO❞K MARK"KYu. €•)

}" (ŒNAME"ŒIROHAN"ŒROLL_NO"KIŒMARK"Kdu.€•)

}" (CHINAME"CHIGUGAN"

PYTHON PROGRAM - 27
AIM:- write a program to get the records from the binary
file student

CODE:-

import pickle

student={}

fin=open("student.dat","rb")

try:
print("filestu.dat stores these records")

while True:

student-pickle.load(fin)

print(student)

except EOFError:

fin.close()

OUTPUT:-

student file stores these records

{'NAME': 'HIMESH', 'ROLL_NO': 12, 'MARK': 87} {'NAME': 'RAJA',


'ROLL_NO': 2, 'MARK': 99} {'NAME': 'LALIT', 'ROLL_NO': 3, 'MARK':
89} {'NAME': 'MOHAN', 'ROLL_NO': 23, 'MARK': 100}

{'NAME': 'SOHAN', 'ROLL_NO': 25, 'MARK': 80}

PYTHON PROGRAM - 28
AIM:- write a program to retrieve the records of those
students whose roll no are present in the list of roll
numbers specified by the user

CODE:-

import pickle

student={}
found=False

fin=open("student.dat","rb")

searchkeys=eval(input("enter the roll no to be searvhed"))

try:

print("searching in file student.dat")

while True:

student-pickle.load(fin)

if student["ROLL_NO"] in searchkeys:

print(student)

found=True

except EOFError:

if found == False:

print(" no such records found in the file")

else:

print("search successful.")

fin.close()

OUTPUT:-

enter the roll no to be searched [24,12,14,2]

searching in file student.dat

{'NAME': 'HIMESH', 'ROLL_NO': 12, 'MARK': 87}

{'NAME': 'RAJA', 'ROLL_NO': 2, 'MARK': 99}

search successful.
enter the roll no to be searched [15,7,19,27]

searching in file student.dat

no such records found in the file

PYTHON PROGRAM - 29
AIM:- write a program to update the name of the student
in “student.dat”, by the name specified the user who is
having the roll number which is given by the user

CODE:-
import pickle

student={}

found=False

N=int(input("enter roll number")) m=input("enter name")


fin=open("student.dat","rb+")

try:

while True:

rpos=fin.tell() student-pickle.load(fin)

if student["ROLL_NO"]==N:

student["NAME"]==m fin.seek(rpos)

pickle.dump(student,fin)

found=True

except EOFError:

if found == False:

print("not matching")

else:

print("succussfully updated.")

fin.close()

OUTPUT:-

enter roll number 23

enter name KAMAL

succussfully updated.
PYTHON PROGRAM - 30
AIM:- write a program to create a csv file and add
records to it

CODE:-

import csv

file=open("CS.CSV","w")

object=csv.writer(file)

object.writerow(["ROLL NO","NAME","MARKS"])

ans="yes"

while ans=="yes":

rollno=int(input("enter roll no"))

name=input("enter name")

marks= float(input("enter marks")) list=[rollno,name,marks]

object.writerow(list)

ans=input("enter yes or no")

file.close()

OUTPUT:
enter roll no 25

enter name rajini

enter marks 89

enter yes or no yes

enter roll no 23

enter name KARTHIK

enter marks 76

enter yes or no yes

enter roll no 34

enter name GUPTA

enter marks 99

enter yes or no yes

enter roll no 21

enter name GUREN

enter marks 100

enter yes or no no

ROLL NO NAME MARKS

25 RAJINI 87

23 KARTHIK 76

34 GUPTA 99

21 GUREN 100
PYTHON PROGRAM - 31

AIM:- write a program to get item details from the user


in the format (code, description and price) for multiple
items from the user and create a csv file by writing all
the item details in one go

CODE:-

import csv

file=open("items.csv","w")

writer=csv.writer(file)

writer.writerow(["CODE","DESCRIPTION","PRICE"])

list=[] ans="Y"

while ans=="Y":

code=int(input("enter the item code"))

description=input("enter the description")

price=float(input("enter the price"))

list.append([code,description,price])

ans=input("enter Y or N")

else:

writer.writerow(list)

print(" insertion successful")

file.close()
OUTPUT:-

enter the item code 1120

enter the description MILK BIKIS

enter the price 20

enter Y or N Y

enter the item code 1123

enter the description FRIED GROUND NUT

enter the price 20

enter Y or N Y

enter the item code 1134

enter the description OREO

enter the price 35

enter Y or N Y

enter the item code 1122

enter the description MUNCH

enter the price 10

enter Y or N Y

enter the item code 1178

enter the description BOURBON

enter the price 30

enter Y or N N
insertion successful

PYTHON PROGRAM - 32
AIM:- STACK IMPLEMENTATION

CODE:-

def isempty(stack):

if stack==[]:

return True

else:

return False

def push(stack,item):

stack.append(item) TOP= len(stack)-1

def pop(stack):

if isempty(stack):

return "UNDERFLOW"

else:

item=stack.pop()

if len(stack) ==0:

TOP = None

else:

TOP = len(stack)-1
return item

def peek(stack):

ch=int(input("enter 1/2/3/5/4/5 only"))

if ch==1:

item=int(input("enter item"))

push(stack, item)

elif ch==2:

item=pop(stack)

if item=="UNDERFLOW":

print("Underflow! stack is empty")

else:

print("popped item is ",item)

elif ch==3:

item=peek(stack)

if item=="UNDERFLOW":

print("Underflow! stack is empty")

else:

print("Topmost element is",item)

elif ch==4:

display(stack)

elif ch==5:
break

else:

print("enter only 1/2/3/4/5") ans=input("enter Y or N")

OUTPUT:-

STACK IMPLEMENTATION

MAIN MENU

1.PUSH AN ELEMENT INTO THE STACK

2.POP AN ELEMENT FROM THE STACK

3.DISPLAY THE TOP ELEMENT IN THE STACK

4.TO DISPLAY THE STACK

enter 1/2/3/5/4/5 only 1

enter item 1

enter Y or N Y

STACK IMPLEMENTATION

MAIN MENU

1.PUSH AN ELEMENT INTO THE STACK

2.POP AN ELEMENT FROM THE STACK

3.DISPLAY THE TOP ELEMENT IN THE STACK

4.TO DISPLAY THE STACK


enter 1/2/3/5/4/5 only 1

enter item 2

enter Y or N Y

STACK IMPLEMENTATION

MAIN MENU

1.PUSH AN ELEMENT INTO THE STACK

2.POP AN ELEMENT FROM THE STACK

3.DISPLAY THE TOP ELEMENT IN THE STACK

4.TO DISPLAY THE STACK

enter 1/2/3/5/4/5 only 1

enter item 7

enter Y or N Y

STACK IMPLEMENTATION

MAIN MENU

1.PUSH AN ELEMENT INTO THE STACK

2.POP AN ELEMENT FROM THE STACK

3.DISPLAY THE TOP ELEMENT IN THE STACK

4.TO DISPLAY THE STACK

enter 1/2/3/5/4/5 only 1

enter item 3

enter Y or N Y
STACK IMPLEMENTATION

MAIN MENU

1.PUSH AN ELEMENT INTO THE STACK

2.POP AN ELEMENT FROM THE STACK

3.DISPLAY THE TOP ELEMENT IN THE STACK

4.TO DISPLAY THE STACK

enter 1/2/3/5/4/5 only 1

enter item3 2

enter Y or N Y

STACK IMPLEMENTATION

MAIN MENU

1.PUSH AN ELEMENT INTO THE STACK

2.POP AN ELEMENT FROM THE STACK

3.DISPLAY THE TOP ELEMENT IN THE STACK

4.TO DISPLAY THE STACK

enter 1/2/3/5/4/5 only 1

enter item 9

enter Y or NY

STACK IMPLEMENTATION

MAIN MENU

1.PUSH AN ELEMENT INTO THE STACK


2.POP AN ELEMENT FROM THE STACK

3.DISPLAY THE TOP ELEMENT IN THE STACK

4.TO DISPLAY THE STACK

enter 1/2/3/5/4/5 only 2

popped item is 9

enter Y or N Y

STACK IMPLEMENTATION

MAIN MENU

1.PUSH AN ELEMENT INTO THE STACK

2.POP AN ELEMENT FROM THE STACK

3.DISPLAY THE TOP ELEMENT IN THE STACK

4.TO DISPLAY THE STACK

enter 1/2/3/5/4/5 only 2

popped item is 32

enter Y or N Y

STACK IMPLEMENTATION

MAIN MENU

1.PUSH AN ELEMENT INTO THE STACK

2.POP AN ELEMENT FROM THE STACK

3.DISPLAY THE TOP ELEMENT IN THE STACK

4.TO DISPLAY THE STACK


enter 1/2/3/5/4/5 only 3

Topmost element is 3

enter Y or N Y

STACK IMPLEMENTATION

MAIN MENU

1.PUSH AN ELEMENT INTO THE STACK

2.POP AN ELEMENT FROM THE STACK

3.DISPLAY THE TOP ELEMENT IN THE STACK

4.TO DISPLAY THE STACK

enter 1/2/3/5/4/5 only 4

3742

3 <----- TOP

enter Y or N Y

STACK IMPLEMENTATION

MAIN MENU

1.PUSH AN ELEMENT INTO THE STACK

2.POP AN ELEMENT FROM THE STACK

3.DISPLAY THE TOP ELEMENT IN THE STACK


4.TO DISPLAY THE STACK

enter 1/2/3/5/4/5 only 7

enter only 1/2/3/4/5

enter Y or N Y

STACK IMPLEMENTATION

MAIN MENU

1.PUSH AN ELEMENT INTO THE STACK

2.POP AN ELEMENT FROM THE STACK

3.DISPLAY THE TOP ELEMENT IN THE STACK

4.TO DISPLAY THE STACK

enter 1/2/3/5/4/5 only 5

PYTHON MYSQL INTERFACE-1


Code :-

Table creation and insertion of records

Query-1

Output

Query-2

Output
Query-3

Output

Query-4

Output

PYTHON MYSQL INTERFACE-2


Code :-

Table creation and insertion of records

Query-1

Output
Query-2

Output

Query-3

Output
PYTHON MYSQL INTERFACE-3

Code :-

Table creation and insertion of records

Query-1
Output

Query-2

Output

Query-3

Output

Query-4

Output
SINGLE TABLE TYPE

TABLE 1

FRESH

QUERY-1 QUERY-2

OUTPUT OUTPUT
QUERY-3 QUERY-4

OUTPUT OUTPUT
TABLE 2

STUDENT

QUERY-1

OUTPUT

QUERY-2
OUTPUT

QUERY-3

OUTPUT

TABLE 3

TEACHER

QUERY-1

OUTPUT

QUERY-2
OUTPUT

→empty table

QUERY-3

OUTPUT

QUERY-4

OUTPUT
QUERY-5

OUTPUT

QUERY-6

OUTPUT

DOUBLE TABLE TYPE

1.

FLIGHT

PASSENGER
QUERY-1

OUTPUT

QUERY-2

OUTPUT

QUERY-3

OUTPUT

QUERY-4
← DELETED RECORD

2.

DEPT

WORKER

QUERY-1

OTUPUT
QUERY-2

OUTPUT

QUERY-3

OUTPUT

QUERY-4

OUTPUT

QUERY-5
OUTPUT

QUERY-6

OUTPUT

QUERY-7

OUTPUT

3.

PRODUCT

BRAND
QUERY-1

OUTPUT

QUERY-2

OUTPUT

QUERY-3

OUTPUT
QUERY-4

OUTPUT

You might also like