You are on page 1of 4

Q1 To write a menu driven program in Python to create a stack name Book_Stack, which takes the names of

Books and implement all operations (Push, POP ,Peek and Traversal) on stack Book_Stack
Or
To write a menu driven program in Python to store and display details of student(rollno, name and class )in
stud.dat file using binary file handling.

Q2 To write a program to connect Python with MySQL using database connectivity and perform the
following operations on data in database: Create a table, Insert the data,Fetch the data, update the data,
and delete the data.
import
mydb=mysql.connector.connect(host="localhost",user="root",passwd="root",database="lib")
if mydb. :
print("Connection oK.")
else:
print("Error connecting to mysql database.")
myc =mydb.
myc.execute("CREATE TABLE library (bookid INT(5), bookname CHAR(10), book_price
int(5));")
myc.execute("INSERT INTO library VALUES (120, 'Ramayana', 500);")
myc.execute("INSERT INTO library VALUES (150, 'Alice in Wonderland', 250);")
myc.execute("INSERT INTO library VALUES (221, 'Wings of Fire', 300);")
myc.execute("SELECT * FROM library;")

Q3 To write a menu driven program in Python to create a stack name Result_Stack, which takes the records
of Result (Rno,Name,Class,Percent)and implement all operations (Push, POP ,Peek and Traversal) on
stack Result_Stack
Or
To write a menu driven program in Python to store and display details of bank(accno, name and bal )in
bank.txt file using text file handling.

Q4 To write a program to connect Python with MySQL using database connectivity and perform the
following operations on data in database: Create a table, Insert the data,Fetch the data, update the
data, and delete the data
import
mydb=mysql.connector.connect(host="localhost",user="root",passwd="root",database="train")
if mydb. :
print("Connection oK.")
else:
print("Error connecting to mysql database.")
myc =mydb.
myc.execute("CREATE TABLE reservation (pnrno INT(8), pass_name CHAR(10), ticket_price
int(5));")
myc.execute("INSERT INTO reservation VALUES (12010, 'Ram', 500);")
myc.execute("INSERT INTO reservation VALUES (15011, 'Alice’, 2500);")
myc.execute("INSERT INTO reservation VALUES (22100, ‘Waqar’, 700);")
myc.execute("SELECT * FROM reservation;")
Q5 To write a menu driven program in Python to create a stack name bank_Stack, which stores
accno,accname & accbal of customers & implement all operations (Push, POP ,Peek and Traversal) on
stack Bank_Stack
Or
To write a menu driven program in Python to store and display details of emp(empno, name and sal )in
emp.csv file using csv files.

Q6 To write a program to connect Python with MySQL using database connectivity and perform the
following operations on data in database: Create a table, Insert the data,Fetch the data, update the data,
and delete the data
import
mydb=mysql.connector.connect(host="localhost",user="root",passwd="root",database="transaction")
if mydb. :
print("Connection oK.")
else:
print("Error connecting to mysql database.")
myc =mydb.
myc.execute("CREATE TABLE fee (studid INT(5), studname CHAR(10), stud_fee int(5));")
myc.execute("INSERT INTO fee VALUES (101, 'Rohit', 3500);")
myc.execute("INSERT INTO fee VALUES (102, 'Aruna', 2750);")
myc.execute("INSERT INTO fee VALUES (103, ‘Faiz’, 3000);")
myc.execute("SELECT * FROM fee;")

Q7 To write a menu driven program in Python to create a stack name Stud_Stack, which stores the record of
Students(rollno,name,class)and implement all operations (Push, POP ,Peek and Traversal) on stack
Stud_Stack.
Or
To write a menu driven program in Python to store and display details of loan(loanno, name and loan_amt
)in loan.dat file using binary file handling.

Q8 To write a program to connect Python with MySQL using database connectivity and perform the
following operations on data in database: Create a table, Insert the data,Fetch the data, update the data,
and delete the data
import
mydb=mysql.connector.connect(host="localhost",user="root",passwd="root",database="demo")
if mydb. :
print("Connection oK.")
else:
print("Error connecting to mysql database.")
myc =mydb.
myc.execute("CREATE TABLE result (rollno INT(5), name CHAR(10), grade char (5));")
myc.execute("INSERT INTO result VALUES (1011, 'Suyash'),’A1’)")
myc.execute("INSERT INTO result VALUES (1012, ‘Aiman’, ‘B1’);")
myc.execute("INSERT INTO result VALUES (1013, 'Isha', ‘C1’);")
myc.execute("SELECT * FROM result”)

Q9 To write a menu driven program in Python to create a stack name reservation_Stack, which maintains
pnrno,name,ticket_fare and implement all operations (Push, POP ,Peek and Traversal) on stack
reservation_Stack.
Or
To write a menu driven program in Python to store and display details of book(accession_no, book_name
and writer_name )in book.txt file using text file handling.

Q10 To write a program to connect Python with MySQL using database connectivity and perform the
following operations on data in database: Create a table, Insert the data,Fetch the data, update the data,
and delete the data
import
mydb=mysql.connector.connect(host="localhost",user="root",passwd="root",database="public")
if mydb. :
print("Connection oK.")
else:
print("Error connecting to mysql database.")
myc =mydb.
myc.execute("CREATE TABLE student(id INT(5), name CHAR(10), marks int(5));")
myc.execute("INSERT INTO student VALUES (12010, 'Ramaya', 500);")
myc.execute("INSERT INTO student VALUES (12011, 'Alice', 250);")
myc.execute("INSERT INTO student VALUES (12012, 'Wasim', 300);")
myc.execute("SELECT * FROM student;")

Q11 To write a menu driven program in Python to create a stack name emp_Stack, stotes empno,ename &
esal ,implement all operations (Push, POP ,Peek and Traversal) on stack emp_Stack.
Or
To write a menu driven program in Python to store and display details of fee(rollno, name and fee_amt )in
fee.csv file using csv files.

Q12 To write a program to connect Python with MySQL using database connectivity and perform the
following operations on data in database: Create a table, Insert the data,Fetch the data, update the data,
and delete the data
import
mydb=mysql.connector.connect(host="localhost",user="root",passwd="root",database="data")
if mydb. :
print("Connection oK.")
else:
print("Error connecting to mysql database.")
myc =mydb.
myc.execute("CREATE TABLE course (courseid INT(5),coursename CHAR(10), courseprice
int(5));")
myc.execute("INSERT INTO course VALUES (120, 'BCA', 50000);")
myc.execute("INSERT INTO course VALUES (150, ‘MBA’, 65000);")
myc.execute("INSERT INTO course VALUES (221, ‘MCA', 30000);")
myc.execute("SELECT * FROM course;")

Q13To write a menu driven program in Python to create a stack name loan_Stack, which
maintains(loan_num,loan_date,loan_amt) and implement all operations (Push, POP ,Peek and Traversal)
on stack loan_Stack.
Or
To write a menu driven program in Python to store and display details of reservation(pnr, source and
destination )in res.dat file using binary file handling.

Q14 To write a program to connect Python with MySQL using database connectivity and perform the
following operations on data in database: Create a table, Insert the data,Fetch the data, update the data,
and delete the data
import
mydb=mysql.connector.connect(host="localhost",user="root",passwd="root",database="company")
if mydb. :
print("Connection oK.")
else:
print("Error connecting to mysql database.")
myc =mydb.
myc.execute("CREATE TABLE emp(empid INT(5), empname CHAR(10), empsal int(5));")
myc.execute("INSERT INTO emp VALUES (11120, 'yana', 50000);")
myc.execute("INSERT INTO emp VALUES (11150, 'sai', 25000);")
myc.execute("INSERT INTO emp VALUES (11221,’ virat', 30000);")
myc.execute("SELECT * FROM emp;")

Q15 To write a menu driven program in Python to create a stack name fee_Stack, which stores adm_no,name,fee_amt
and implement all operations (Push, POP ,Peek and Traversal) on stack fee_Stack
Or
To write a menu driven program in Python to store and display details of result(rollno, name and grade )in result.txt
file using text file handling.

Q16 To write a program to connect Python with MySQL using database connectivity and perform the following
operations on data in database: Create a table, Insert the data,Fetch the data, update the data, and delete the data
import
mydb=mysql.connector.connect(host="localhost",user="root",passwd="root",database="bank")
if mydb. :
print("Connection oK.")
else:
print("Error connecting to mysql database.")
myc =mydb.
myc.execute("CREATE TABLE loan (loanid INT(5), loan_date date, loan_amt int(7));")
myc.execute("INSERT INTO loan VALUES (1020, '2020-05-09', 500000);")
myc.execute("INSERT INTO loan VALUES (1050, 2015-05-07’, 200000);")
myc.execute("INSERT INTO loan VALUES (2021, '2021-11-09', 300000);")
myc.execute("SELECT * FROM loan;")

You might also like