You are on page 1of 18

Computer Science

Practical File
2021-2022

Shailendra kumar
RPVV INA Colony
Class XII-A
Roll no. 17
Rajkiya Pratibha Vikas
Vidyalaya
Certificate
“Computer Science Practical file session 2021-2022“

Shailendra Kumar of class XII-A for the CBSE Senior


Secondary Examination class XII of Computer Science at
Rajkiya Pratibha Vikas Vidyalaya INA Colony has been
examined.

Signature of Examiner
INDEX
SL Name of Date of Date of
NO. Practical Practica Submission Remarks
l s
1. Write a program to
implement a stack
using list.

2. MySQL Alter table


query

3. Update command in
MySQL

4. To order by table in
ascending/descending
order

5. To perform delete
command in MySQL

6. Joins in MySQL
Practical 1
Aim: Write a program to implement a stack using list.
Program:
# push element
def push(list, element):
list.append(element)
return list

# pop element
def pop(list):
a = list.pop()
return list, " element popped... ", a

# peek element
def peek(list):
return "peek element: ", list[-1]

# display elements
def display(list):
l = len(list)
for i in range(l - 1, -1, -1):
print(list[i])
# __main__
stack = []
run = True
while run:
ask = int(input("1. push element \n"
"2. pop element\n"
"3. peek element\n"
"4. display elements \n"
"5. quit\n"
"enter your choice:\n".title()))
if ask == 1:
a = int(input("enter element to push in to stack:\n"))
print(push(stack, a), "\n")

if ask == 2:
if len(stack) == 0:
print("Empty Stack..\n")
else:
print(pop(stack), "\n")

if ask == 3:
print(peek(stack), "\n")
if ask == 4:
display(stack)
print("")

if ask == 5:
run= False
Output:
Practical 2

Aim: Alter table query in MySQL.


Program:
Show Databases
show databases;

Use Databases and show tables


use databases
show tables
Table

Alter table
alter table xii_a_student_personal_detail add column behavior varchar(10);
alter table xii_a_student_personal_detail drop column behavior;
Practical 3

Aim: To update data in table


Program:

update xii_a_student_personal_detail set address='Chhatarpur' where


name=’Falweeca’
Practical 4

Aim: To order by table in ascending/descending order


Program:

Table

select * from xii_a_marks_sheet order by average_marks;


select * from xii_a_marks_sheet order by average_marks desc;

select * from xii_a_marks_sheet where average_marks>95 order by average_marks


desc;
Practical 5

Aim: To perform delete command in MySQL


Program:
● Deleting a row in table

delete from xii_a_marks_sheet where where


name='muskan';
Practical 6
Aim: To join two tables

Program:
● Inner join
select * from pc;
select * from record;
select * from record as r inner join pc on r.name=pc.name;
● Natural join
Select * from record natural join pc;

You might also like