Python and SQL Practice Questions
Python and SQL Practice Questions
ANSWER
Python (08m) SQL(04m) Record(07) Project(08) Viva(3m)
stk=[]
def push():
bookno=int(input("enter book number"))
bname=input("enter book name")
price=int(input("Enter price"))
b=[bookno,bname,price]
stk.append(b)
def pop():
if len(stk)==0:
print("stack empty")
else:
print("The popped element is:",stk.pop())
def display():
if len(stk)==0:
print("stack empty")
else:
for i in stk[::-1]:
print(i)
while True:
print(""" MENU
1. PUSH
2. POP
3. DISPLAY"""
)
ch=int(input("Enter your choice: (1/2/3)"))
if ch==1:
push()
elif ch==2:
pop()
elif ch==3:
display()
else:
break
1. SQL
Numb
Gcode GameName Type er Prizemoney Scheduledate
101 Carom Board Indoor 2 5000 23-jan-2004
102 Badminton Outdoor 2 12000 12-Dec-2003
103 Table Tennis Indoor 4 8000 14-Feb-2004
105 Chess Indoor 2 9000 01-jan-2004
108 Lawin Tennis Outdoor 4 25000 19-Mar-2004
(a) Display the details of outdoor games from the table games.
(b) Display details of those Games which are having Prizemoney more than 7000.
(c ) Display details of table Games in descending order of prizemoney
(d) Display sum of prizemoney for each type of Games.
Numb
Gcode GameName Type er Prizemoney Scheduledate
101 Carom Board Indoor 2 5000 23-jan-2004
102 Badminton Outdoor 2 12000 12-Dec-2003
103 Table Tennis Indoor 4 8000 14-Feb-2004
105 Chess Indoor 2 9000 01-jan-2004
108 Lawin Tennis Outdoor 4 25000 19-Mar-2004
(a) Display the details of outdoor games from the table games.
(b) Display details of those Games which are having Prizemoney more than 7000.
(c ) Display details of table Games in descending order of prizemoney
(d) Display sum of prizemoney for each type of Games.
(a) Display FL_NO and NO_FLIGHTS from “KANPUR” to “BANGLORE” from the table
FLIGHTS.
(b) Display the contents of the table FLIGHTS in the ascending order of FL_NO.
(c) Display flight details whose ending is “Mumbai”
(d) Display number of records in the table Flights
(a) Display FL_NO and NO_FLIGHTS from “KANPUR” to “BANGLORE” from the table
FLIGHTS.
(b) Display the contents of the table FLIGHTS in the ascending order of FL_NO.
(c) Display flight details whose ending is “Mumbai”
(d) Display number of records in the table Flights
1. Write a Python program to create a emp.CSV file with empid, name and mobile number. Search by name and
display the records.
2. Write the SQL command for the following statements (i) to (iv)
Table : Faculty
F_I
D Fname Lname Hire_date Salary
102 Amit Mishra 12-10-1998 12000
103 Nitin Vyas 24-12-1994 8000
104 Rakshit Soni 18-05-2001 14000
105 Rashmi Malhotra 11-09-2004 11000
106 Sulekha Srivastava 05-06-2006 10000
(a) Display details of those Faculties whose salary is greater than 12000.
i (b) Display the details of courses whose fees is in the range of 15000 to 50000 (both
values included).
iii (c ) Increase the salary by 5000 of “Amit” .
i (d) Display details of Faculty in descending order of salary.
v
1.Write a Python program to create a emp.CSV file with empid, name and mobile number. Search by name and
display the records.
2. Write the SQL command for the following statements (i) to (iv)
Table : Faculty
F_I
D Fname Lname Hire_date Salary
102 Amit Mishra 12-10-1998 12000
103 Nitin Vyas 24-12-1994 8000
104 Rakshit Soni 18-05-2001 14000
105 Rashmi Malhotra 11-09-2004 11000
106 Sulekha Srivastava 05-06-2006 10000
(a) Display details of those Faculties whose salary is greater than 12000.
i (b) Display the details of courses whose fees is in the range of 15000 to 50000 (both
values included).
iii (c ) Increase the salary by 5000 of “Amit” .
i (d) Display details of Faculty in descending order of salary.
COMPUTER SCIENCE 083 MAX. MARKS: 30
CLASS : XII SET-5 TIME ALLOWED :3. 00 hrs
2) Write the SQL command for the following statements (i) to (iv)
Games
Numb
Gcode GameName Type er Prizemoney Scheduledate
101 Carom Board Indoor 2 5000 23-jan-2004
102 Badminton Outdoor 2 12000 12-Dec-2003
103 Table Tennis Indoor 4 8000 14-Feb-2004
105 Chess Indoor 2 9000 01-jan-2004
108 Lawin Tennis Outdoor 4 25000 19-Mar-2004
(a) Display the details of outdoor games from the table games.
(b) Display details of those Games which are having Prizemoney more than 7000.
(c ) Display details of table Games in descending order of prizemoney
(d) Display sum of prizemoney for each type of Games.
2) Write the SQL command for the following statements (i) to (iv)
Games
Numb
Gcode GameName Type er Prizemoney Scheduledate
101 Carom Board Indoor 2 5000 23-jan-2004
102 Badminton Outdoor 2 12000 12-Dec-2003
103 Table Tennis Indoor 4 8000 14-Feb-2004
105 Chess Indoor 2 9000 01-jan-2004
108 Lawin Tennis Outdoor 4 25000 19-Mar-2004
(a) Display the details of outdoor games from the table games.
(b) Display details of those Games which are having Prizemoney more than 7000.
(c ) Display details of table Games in descending order of prizemoney
(d) Display sum of prizemoney for each type of Games.
(a) Display FL_NO and NO_FLIGHTS from “KANPUR” to “BANGLORE” from the table
FLIGHTS.
(b) Display the contents of the table FLIGHTS in the ascending order of FL_NO.
(c) Display flight details whose ending is “Mumbai”
(d) Display number of records in the table Flights
(a) Display FL_NO and NO_FLIGHTS from “KANPUR” to “BANGLORE” from the table
FLIGHTS.
(b) Display the contents of the table FLIGHTS in the ascending order of FL_NO.
(c) Display flight details whose ending is “Mumbai”
(d) Display number of records in the table Flights