In this article, I am going to discuss Important Computer Science Board Practical Paper 2 Solution 2024. Let us begin!
Topics Covered
Computer Science Board Practical Paper 2 Solution 2024
I have already discussed the solution Computer Science Board Practical Paper 1 Solution 2024 recently. Here we are going to discuss a solution for Computer Science Board Practical Paper 2 Solution 2024. Here we go!
In this Computer Science Board Practical Paper 2 the first question is based on the Stack topic. A menu-driven program is asked. Let’s see how to solve this!
Question 1 – Stack Menu-Driven Program
The question 1 is asked in the 8-mark component. The question is:
Write a menu drive program to Python to implement stack using a list and perform the following functions:
- Push
- Pop
- Display
- Exit
Solution
stk=[]
def push(stk,ele):
stk.append(ele)
top=len(stk)-1
def Pop(stk):
if len(stk)==0:
return "Underflow"
else:
pop_item=stk.pop()
if len(stk)==0:
top=None
else:
top=len(stk)-1
return pop_item
def display(stk):
if len(stk)==0:
return "Underflow"
else:
top=len(stk)-1
print(stk[top],"<-top")
for i in range(top-1,-1,-1):
print(stk[i])
while True:
print('''
1. Push
2. Pop
3. Display
4. Exit
''')
ch=int(input("Enter your choice:"))
if ch==1:
e=int(input("Enter the value to push:"))
push(stk,e)
elif ch==2:
i=Pop(stk)
if i=='Underflow':
print("Underflow! Stack is empty")
else:
print("Popped Item",i)
elif ch==3:
display(stk)
elif ch==4:
break
else:
print("Invalid Choice")
Question 2 – MySQL Queries
Question 2 of Computer Science Board Practical Paper 2 is based on MySQL queries. The question is:
Consider the books and issue of the table and write SQL commands for given statements:
(i) Write a command to add primary key and foreign key in tables using alter.
Ans.:
alter table books add primary key (BID);
alter table issued add foreign key references books (bid);
(ii) Increase the price of all computer books by 70.
Ans.:
update books set price=price + 70 where type='computer';
(iii) Display the book id, book name, and quantity issued for all books that have been issued.
Ans.:
select books.bid,bname,qty_issued from books,issued where books.bid=issued.bid;
(iv) Display the book ID, book name, author name, and quantity issued for all books whose price are 200 to 400.
Ans.:
select books.bid,bname,auname,qty_issued from books,issued
where books.bid=issued.bid and price>=200 and price<=400;
OR
select books.bid,bname,auname,qty_issued from books,issued
where books.bid=issued.bid and price between 200 and 400;
Follow the given link to get the question papers:
Watch this video to understand the solution practically:
Thank you for visiting!