0% found this document useful (0 votes)
15 views5 pages

Aissce CS Practical Exam 2021

Y
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)
15 views5 pages

Aissce CS Practical Exam 2021

Y
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/ 5

PREBOARD PRACTICAL EXAM 2021

SUB: Computer Science (SUB CODE 083)


Date: 22.03.2021 SET A [F.M. 30]

1. Write and run python code to implement a stack.[7 marks]

2. SQL [5 Marks]
Consider the table ITEM with ITEMNO as primary key .
Table:ITEM
ITMNO ITEMNAME PRICE
1001 KEYBOARD 250
1002 MOUSE 200
1003 PRINTER 8000
1004 MONITOR 4000

i)Write SQL command to create the above table.


ii)Write SQL command to insert the first record.

Write SQL command for (iii) & (iv) using database connectivity with python
code:

iii) Display the details of items in alphabetical order of name.


iv) Display the maximum price.

3.Report File [7 Marks]


4.Project Work [8 Marks]
5.Viva [3 Marks]

[****]
PREBOARD PRACTICAL EXAM 2021
SUB: Computer Science (SUB CODE 083)
Date: 22.03.2021 SET B [F.M. 30]

1. Write python code to store Roll and name of any three students in a Binary
file and display the name of students with roll =2.[7 marks]

2.SQL [5 Marks]
Consider the table ITEM with ITEMNO as primary key .
Table:ITEM
ITMNO ITEMNAME PRICE
1001 KEYBOARD 250
1002 MOUSE 200
1003 PRINTER 8000
1004 MONITOR 4000

i)Write SQL command to create the above table.


ii)Write SQL command to insert the first record.

Write SQL command for (iii) & (iv) using database connectivity with python
code:

iii) Display the details of items in alphabetical order of name.


iv) Display the maximum price.

3.Report File [7 Marks]


4.Project Work [8 Marks]
5.Viva [3 Marks]

[****]
Answer:-SET A
1.Satck Implementation
s=[]
print("1.PUSH")
print("2.POP")
print("3.Display")
choice="y"
while choice=="y":
x=int(input("Please enter your choice 1, 2 or 3"))
if x==1:
value=int(input("Enter value to be pushed"))
s.append(value)
if x==2:
if s==[]:
print("Stack is Empty")
else:
z=s.pop()
print("the popped element is=",z)
if x==3:
print(s)
choice=input("Do you want to continue? press y else press any key")

print("Process Over")

output of the program:

2.SQL
i)CREATE TABLE ITEM(ITEMNO INTEGER PRIMARY KEY, ITEMNAME VARCHAR(20), PRICE
DECIMAL(8,2));
ii)INSERT INTO ITEM VALUES(1001,’KEYBOARD’,250);

iii)
import mysql.connector

mydb = mysql.connector.connect(
host="localhost",
user="root",
password="dav",
database="school")

mycursor = mydb.cursor()
query1=("SELECT * FROM ITEM ORDER BY ITEMNAME")
mycursor.execute(query1)
myresult = mycursor.fetchall()
for x in myresult:
print(x)

query2= “SELECT MAX(PRICE) FROM ITEM"


mycursor.execute(query2)
myresult = mycursor.fetchall()
for x in myresult:
print(x)

output of the SQL (iii)


ITMNO ITEMNAME PRICE
1001 KEYBOARD 250
1004 MONITOR 4000
1002 MOUSE 200
1003 PRINTER 8000

output of the SQL (iv)


MAX(PRICE)
8000.00

[****]
Answer:-SET B
1.Binary file Writing and Reading
#writing and reading a binary file
import pickle
record=[]
for x in range(3):
roll=int(input("Enter roll of student"))
name=input("Enter a name of student")
data=[roll,name]
record.append(data)
f=open('student.dat','wb')
pickle.dump(record,f)
f.close()
#writing completed
#Reading of file
f=open('student.dat','rb')
record=pickle.load(f)
for x in record:
if(x[0]==2):
roll=x[0]
name=x[1]
print('Roll:',roll, 'Name:', name)
f.close()

output of the program:


2.SQL
i)CREATE TABLE ITEM(ITEMNO INTEGER PRIMARY KEY, ITEMNAME VARCHAR(20), PRICE
DECIMAL(8,2));
ii)INSERT INTO ITEM VALUES(1001,’KEYBOARD’,250);

iii)
import mysql.connector

mydb = mysql.connector.connect(
host="localhost",
user="root",
password="dav",
database="school")

mycursor = mydb.cursor()
query1=("SELECT * FROM ITEM ORDER BY ITEMNAME")
mycursor.execute(query1)
myresult = mycursor.fetchall()
for x in myresult:
print(x)

query2= “SELECT MAX(PRICE) FROM ITEM"


mycursor.execute(query2)
myresult = mycursor.fetchall()
for x in myresult:
print(x)

output of the SQL (iii)


ITMNO ITEMNAME PRICE
1001 KEYBOARD 250
1004 MONITOR 4000
1002 MOUSE 200
1003 PRINTER 8000

output of the SQL (iv)


MAX(PRICE)
8000.00

[*****]

You might also like