SlideShare a Scribd company logo
1
Practical file-
in
Computer Sc.-083
for
Session 2021-22
LOGO OF YOUR SCHOOL
XYZ school , NEW DELhi-110011
2
Certificate
This is to certify that __________________ ,
Roll No. _____ of Class 12th Session 2021-22
has prepared the Practical File as per the
prescribed Practical Syllabus of Computer
Science Code-083, Class-12 AISSCE (CBSE)
under my supervision.
It is the original work done by him/her. His/ her
work is really appreciable.
I wish him/her a very bright success.
__________________
Signature of Teacher.
__________________
Signature of External
3
Index
S.No. Practical Description Page
No.
Date Teacher's
Sign.
1 Practical No. -1
2 Practical No. -2
3 Practical No. -3
4 Practical No. -4
5 Practical No. -5
6 Practical No. -6
7 Practical No. -7
8 Practical No. -8
9 Practical No. -9
10 Practical No. -10
11 Practical No. -11
12 Practical No. -12
13 Practical No. -13
14 Practical No. -14
15 Practical No. -15
16 Practical No. -16
17 Practical No. -17
18 Practical No. -18
19 Practical No. -19
20 Practical No. -20
21 Practical No. -21
22 Practical No. -22
23 Practical No. -23
24 Practical No. -24
25 Practical No. -25
4
26 Practical No. -26
27 Practical No. - 27
28 Practical No. -28
29 Practical No. -29
30 Practical No. -30
31 Practical No. -31
5
MySQL- SQL Commands
6
Practical No-1
Date: 27/12/2021
Problem- Create a database 'csfile' on the database server, show the list of databases and
open it.
Solution :
> create database csfile;
> show databases;
> use csfile;
Command and output ( Screenshot ) :
7
Practical No-2
Date: 27/12/2021
Problem- Create the following table named 'Dept' and 'Emp' with appropriate data type, size
and constraint(s). Show its table structure also.
Solution :
create table dept(deptno int(2) primary key, dname varchar(10),
Location varchar(15));
Table structure:
Command : desc dept;
create table Emp(Empno int(4) primary key, Ename varchar(15) not null,
Job varchar(10), MGR int(4), Hiredate date, Sal double(8,2) check (sal>10000),
Comm double(7,2), Deptno int(2) references Dept(deptno));
8
Practical No-3
Date: 27/12/2021
Problem- insert few records/tuples into the table. Verify the entered records.
Solution :
insert into dept values(10, 'Accounts', 'Delhi');
Note : issued similar commands for other records.
9
10
Practical No-4
Date: 28/12/2021
Problem- Display all the information of employees whose job is NEITHER Manager nor Clerk.
Solution-
select * from emp where job not in ('Manager', 'Clerk');
11
Practical No-5
Date: 28/12/2021
Problem- Display the details of all the employees whose Hiredate is after December 1991.
(consider the Sql’s standard date format)
Solution:
select * from student where Hiredate>'1991-12-31';
Practical No-6
Date: 28/12/2021
Problem- Display the details of all the employees whose Hiredate is maximum. (consider the Sql’s
standard date format)
Solution:
select * from emp where Hiredate=(select max(hiredate) from emp);
12
Practical No-7
Date: 29/12/2021
Problem- Display all information of Clerk and Manager in descending salary wise.
Solution:
select * from emp where job in('Clerk','Manager') order by sal desc;
OR
select * from emp where job ='Clerk' or job='Manager' order by sal desc;
13
Practical No-8
Date: 29/12/2021
Problem-Display all columns arranged in descending order of Job and within the Job in the ascending
order their Names.
Solution:
select * from emp order by Job desc, Sal;
14
Practical No-9
Date: 10/01/2022
Problem- List all employees whose name has the character ‘a’.
Solution:
Select * from emp where Ename like '%a%';
15
Practical No-10
Date: 10/01/2022
Problem- Display Name and Salary of those Employees whose Salary is in the range 40000 and
100000 ( both are inclusive)
Solution:
select EName, Sal from Emp where Sal between 40000 and 100000;
16
Practical No-11
Date: 11/01/2022
Problem- Display those records whose commission is nothing.
Solution:
select * from emp where Comm is null;
17
Practical No-12
Date: 11/01/2022
Problem- Display average Salary, highest Salary and total no. of Employees for each
department.
Solution:
Select deptno, avg(Sal), Max(Sal), Count(*), from Emp group by deptno;
Practical No-13
Date: 11/01/2022
Problem- Display total no of Clerk, Manager, Analyst, Salesman and Salesman along with their average
Salary.
Solution:
Select Job, count(*), avg(Sal) from Emp group by Job;
18
Practical No-14
Date: 12/01/2022
Problem- Increase the Salary of 'Clerk' by 5% Sal and verify the updated rows.
Solution:
update Emp set Sal=Sal+(Sal*0.05) where Job = 'Clerk';
19
Practical No-15
Date: 12/01/2022
Problem- Add a new column named Address. ( Take the data type and size yourself) and
verify the table structure.
Solution:
Alter table Emp add address varchar(25);
Practical No-16
Date: 12/01/2022
Problem- Delete the column Address and verify the table structure.
Solution:
Alter table Emp drop column Address;
20
Practical No-17
Date: 13/01/2022
Problem- Display Ename, job, salary and Hiredate of 'Analysts' whose Salary is below 65000
Solution:
Select EName, Job, Salary, Hiredate from Emp where Job='Analyst' and Sal<65000;
Practical No-18
Date: 13/01/2022
Problem- Display unique Jobs.
Solution:
Select distinct Job from Emp;
21
Practical No-19
Date: 13/01/2022
Problem- Display Job and highest Salary of Employee of each type of Job, but only for Clerk
and Manager.
Solution:
Select Job, max(Sal) from Emp group by Job having Job in('Clerk','Manager');
Practical No-20
Date: 14/01/2022
Problem- Display Job and highest Salary of Employee of each type of Job, but only for Clerk,
Manager and Analyst arranged in ascending order of job.
Solution:
Select Job, max(Sal) from Emp group by Job having Job in('Clerk','Manager','Analyst') order
by job;
22
Practical No-21
Date: 14/01/2022
Problem- Find the Cartesian product of both the tables, Emp and Dept.
Solution:
Select * from emp cross join Dept;
23
24
Practical No-22
Date: 14/01/2022
Problem- Write a query to display corresponding information from both the tables using equi-join.
Solution:
Select * from emp, dept where emp.deptno=dept.deptno;
25
Practical No-23
Date: 14/01/2022
Problem- Write a query to display Ename, Job and Salary from Emp and its corresponding Dname
and Location from Dept tables using equi-join.
Solution:
Select Ename, Job, Sal, Dname,Location from emp, dept where emp.deptno=dept.deptno;
26
Practical No-24
Date: 14/01/2022
Problem- Write a query to display corresponding information from both the tables using natural join.
Solution:
Select * from emp natural join dept;
27
Practical No-25
Date: 14/01/2022
Problem- Write a query to display corresponding information from both the tables using natural join.
Solution:
Select * from emp natural join dept order by Ename;
28
Python Segment
29
Practical No-26 (STACK)
Date: 15/01/2022
Problem : Write a program to show push and pop operation using stack.
Solution:
#stack.py
def push(stack,x): #function to add element at the end of list
stack.append(x)
def pop(stack): #function to remove last element from list
n = len(stack)
if(n<=0):
print("Sorry! Stack empty......")
else:
num=stack.pop()
print(num, "is popped out..")
def display(stack): #function to display stack entry
if len(stack)<=0:
print("Sorry! Stack empty.....")
for i in stack:
print(i,end=" ")
#main program starts from here
x=[]
choice=0
while (choice!=4):
print("n********STACK Menu***********")
print("1. push(INSERTION)")
print("2. pop(DELETION)")
print("3. Display ")
print("4. Exit")
choice = int(input("Enter your choice :"))
if(choice==1):
ans='y'
while ans.upper()=='Y':
value = int(input("Enter a value "))
push(x,value)
ans=input('Push more(y/n):')
if ans.upper()=='N':
30
break
if(choice==2):
pop(x)
if(choice==3):
display(x)
if(choice==4):
print("You selected to close this program")
OUTPUT:
31
32
33
34
Practical No-27 (PYTHON CONNECTIVITY)
Date: 16/01/2022
Problem : Write a Program to show MySQL database connectivity in python.
PROGRAM:
import mysql.connector as conn
mydb=conn.connect(host="localhost",user="root",passwd="tiger",database="csfile")
# create new cursor
cur=mydb.cursor()
qry1="select * from emp"
cur.execute(qry1)
data=cur.fetchall()
print(data)
OUTPUT:
35
Practical No-28 (PYTHON CONNECTIVITY)
Date: 17/01/2022
Problem : Write a Program to show how to retrieve records from a database table Emp using
MySQL database connectivity in python.
PROGRAM:
import mysql.connector as conn
try:
mydb=conn.connect(host="localhost",user="root",passwd="tiger",database="csfile")
# create new cursor
cur=mydb.cursor()
qry1="select * from emp"
cur.execute(qry1)
data=cur.fetchall()
print ("EmpNo Emp Name Job MgrNO Hiredate Salary Commission DeptNo")
print("-"*80)
for cols in data:
eno = cols[0]
enm = cols[1]
jb =cols[2]
mg=cols[3]
hdt=cols[4]
sl=cols[5]
com=cols[6]
dpt=cols[7]
print (eno,enm,jb,mg,hdt,sl,com,dpt)
print("-"*80)
except:
print ("Error: unable to fecth data")
mydb.close()
36
OUTPUT:
37
Practical No-29 (PYTHON CONNECTIVITY)
Date: 18/01/2022
Problem : Write a Program to show how to add records in a database table Emp using
MySQL database connectivity in python.
PROGRAM:
import mysql.connector as conn
mydb=conn.connect(host="localhost",user="root",passwd="tiger",database="csfile")
# create new cursor
cur=mydb.cursor()
eno=int(input("Enter Employee number : "))
enm=input('Enter Employee Name : ')
jb=input("Enter Job: ")
mg=int(input("Enter Manager No : "))
hdt=input("Enter Hiredate (yyyy-mm-dd) : ")
sl=float(input('Enter Salary : '))
com=float(input('Enter Commission : '))
dpt=int(input("Enter Deptt. No : "))
sql="INSERT INTO emp VALUES ('%d', '%s' ,'%s','%d','%s','%f','%f','%d')" %(eno,enm,
jb,mg,hdt, sl,com, dpt)
try:
cur.execute(sql)
print("One row entered successfully...")
mydb.commit()
except:
mydb.rollback()
mydb.close()
OUTPUT:
38
Practical No-30 (PYTHON CONNECTIVITY)
Date: 19/01/2022
Problem : Write a Program to show how to update a record in a database table Emp using
MySQL database connectivity in python.
PROGRAM:
import mysql.connector as conn
mydb=conn.connect(host="localhost",user="root",passwd="tiger",database="csfile")
# create new cursor
cur=mydb.cursor()
eno=int(input("Enter Employee number : "))
sl=float(input('Enter Salary : '))
sql="update emp set sal=%f where empno=%d" % (sl,eno)
try:
ans=input("Are you sure you want to update the record : ")
if ans=='y' or ans=='Y':
cur.execute(sql)
print("Emp no-",eno," salary updated successfully...")
mydb.commit()
except Exception as e:
print("Error! Perhaps Emp no is incorrect...",e)
mydb.rollback()
mydb.close()
OUTPUT:
39
Practical No-31 (PYTHON CONNECTIVITY)
Date: 20/01/2022
Problem : Write a Program to show how to DELETE a record from a database table Emp using
MySQL database connectivity in python.
PROGRAM:
import mysql.connector as conn
mydb=conn.connect(host="localhost",user="root",passwd="tiger",database="csfile")
# create new cursor
cur=mydb.cursor()
eno=int(input("Enter Employee number : "))
sql="delete from emp where empno=%d" % (eno)
try:
ans=input("Are you sure you want to delete the record : ")
if ans=='y' or ans=='Y':
cur.execute(sql)
print("Emp no-",eno," record deleted successfully...")
mydb.commit()
except Exception as e:
print("Error! Perhaps Emp no is incorrect...",e)
mydb.rollback()
mydb.close()
OUTPUT:
Teacher's Signature:
_____________________

More Related Content

PDF
Physics Investigatory project on Diffraction
PDF
Computer Project for class 12 CBSE on school management
PPTX
Sustainable Water Resources in India
PDF
Engineering Chemistry - Polymer
PPT
Index Number
DOCX
Tweet sentiment analysis
PPTX
Tourism in India
PPTX
Ensemble Method (Bagging Boosting)
Physics Investigatory project on Diffraction
Computer Project for class 12 CBSE on school management
Sustainable Water Resources in India
Engineering Chemistry - Polymer
Index Number
Tweet sentiment analysis
Tourism in India
Ensemble Method (Bagging Boosting)

What's hot (20)

DOCX
CBSE Class 12 Computer practical Python Programs and MYSQL
DOCX
computer science with python project for class 12 cbse
ODT
Library Management Project (computer science) class 12
PDF
Informatics Practices/ Information Practices Project (IP Project Class 12)
PDF
IP Project for Class 12th CBSE
DOCX
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
PDF
Computer Science Investigatory Project Class 12
PDF
Computer project final for class 12 Students
PDF
On the face of it English project for class 12 students
PDF
(17 - Salt analysis 1 to 24.pdf
PDF
Computer science Project for class 11th and 12th(library management system)
PDF
CBSE Class XII Physics Investigatory Project
PDF
Term 2 CS Practical File 2021-22.pdf
DOCX
Ip library management project
DOCX
Project front page, index, certificate, and acknowledgement
PDF
English Project work.pdf
PDF
Library Management Python, MySQL
PDF
Various factors on which the internal resistance of a cell depends
PDF
Qualitative Analysis of Coconut Water Chemistry Investigatory Project
DOCX
Phyical Education Project Class 12 CBSE on Volleyball
CBSE Class 12 Computer practical Python Programs and MYSQL
computer science with python project for class 12 cbse
Library Management Project (computer science) class 12
Informatics Practices/ Information Practices Project (IP Project Class 12)
IP Project for Class 12th CBSE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
Computer Science Investigatory Project Class 12
Computer project final for class 12 Students
On the face of it English project for class 12 students
(17 - Salt analysis 1 to 24.pdf
Computer science Project for class 11th and 12th(library management system)
CBSE Class XII Physics Investigatory Project
Term 2 CS Practical File 2021-22.pdf
Ip library management project
Project front page, index, certificate, and acknowledgement
English Project work.pdf
Library Management Python, MySQL
Various factors on which the internal resistance of a cell depends
Qualitative Analysis of Coconut Water Chemistry Investigatory Project
Phyical Education Project Class 12 CBSE on Volleyball
Ad

Similar to Complete practical file of class xii cs 2021-22 (20)

PDF
Vishwajeet Sikhwal ,BCA,Final Year 2015
PDF
Divyansh Mehta,BCA Final Year 2015 ,Dezyne E'cole College
PDF
Apurv Gupta, BCA ,Final year , Dezyne E'cole College
PDF
Nikhil Khandelwal BCA 3rd Year
PDF
Pooja Jain
PDF
Pooja Bijawat,Bachelor Degree in Computer Application
PDF
Priyanka Bhatia.BCA Final year 2015
PDF
Vijay Kumar
PDF
Simran kaur,BCA Final Year 2015
DOCX
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docx
PPTX
METHODOLOGY FOR SOLVING EMPLOYEE ATTRITION PROBLEM- Daniel Essien.pptx
PDF
Computer paper 3 may june 2004 9691 cambridge General Certificate of educatio...
PPTX
Complex Queries using MYSQL00123211.pptx
PPTX
Basic Deep Learning.pptx
PDF
@elemorfaruk
PPT
Pseudocode algorithim flowchart
DOC
Programada chapter 4
PPTX
Database Project of a Corporation or Firm
PPTX
ODS Data Sleuth: Tracking Down Calculated Fields in Banner
DOCX
newsql
Vishwajeet Sikhwal ,BCA,Final Year 2015
Divyansh Mehta,BCA Final Year 2015 ,Dezyne E'cole College
Apurv Gupta, BCA ,Final year , Dezyne E'cole College
Nikhil Khandelwal BCA 3rd Year
Pooja Jain
Pooja Bijawat,Bachelor Degree in Computer Application
Priyanka Bhatia.BCA Final year 2015
Vijay Kumar
Simran kaur,BCA Final Year 2015
MSCD650 Final Exam feedback FormMSCD650 Final Exam Grading For.docx
METHODOLOGY FOR SOLVING EMPLOYEE ATTRITION PROBLEM- Daniel Essien.pptx
Computer paper 3 may june 2004 9691 cambridge General Certificate of educatio...
Complex Queries using MYSQL00123211.pptx
Basic Deep Learning.pptx
@elemorfaruk
Pseudocode algorithim flowchart
Programada chapter 4
Database Project of a Corporation or Firm
ODS Data Sleuth: Tracking Down Calculated Fields in Banner
newsql
Ad

Recently uploaded (20)

PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
Pre independence Education in Inndia.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Computing-Curriculum for Schools in Ghana
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Classroom Observation Tools for Teachers
PPTX
Lesson notes of climatology university.
PDF
01-Introduction-to-Information-Management.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Cell Structure & Organelles in detailed.
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPH.pptx obstetrics and gynecology in nursing
Microbial disease of the cardiovascular and lymphatic systems
human mycosis Human fungal infections are called human mycosis..pptx
Final Presentation General Medicine 03-08-2024.pptx
GDM (1) (1).pptx small presentation for students
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Pre independence Education in Inndia.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Computing-Curriculum for Schools in Ghana
VCE English Exam - Section C Student Revision Booklet
Classroom Observation Tools for Teachers
Lesson notes of climatology university.
01-Introduction-to-Information-Management.pdf
O7-L3 Supply Chain Operations - ICLT Program
Anesthesia in Laparoscopic Surgery in India
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Complications of Minimal Access Surgery at WLH
Cell Structure & Organelles in detailed.
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape

Complete practical file of class xii cs 2021-22

  • 1. 1 Practical file- in Computer Sc.-083 for Session 2021-22 LOGO OF YOUR SCHOOL XYZ school , NEW DELhi-110011
  • 2. 2 Certificate This is to certify that __________________ , Roll No. _____ of Class 12th Session 2021-22 has prepared the Practical File as per the prescribed Practical Syllabus of Computer Science Code-083, Class-12 AISSCE (CBSE) under my supervision. It is the original work done by him/her. His/ her work is really appreciable. I wish him/her a very bright success. __________________ Signature of Teacher. __________________ Signature of External
  • 3. 3 Index S.No. Practical Description Page No. Date Teacher's Sign. 1 Practical No. -1 2 Practical No. -2 3 Practical No. -3 4 Practical No. -4 5 Practical No. -5 6 Practical No. -6 7 Practical No. -7 8 Practical No. -8 9 Practical No. -9 10 Practical No. -10 11 Practical No. -11 12 Practical No. -12 13 Practical No. -13 14 Practical No. -14 15 Practical No. -15 16 Practical No. -16 17 Practical No. -17 18 Practical No. -18 19 Practical No. -19 20 Practical No. -20 21 Practical No. -21 22 Practical No. -22 23 Practical No. -23 24 Practical No. -24 25 Practical No. -25
  • 4. 4 26 Practical No. -26 27 Practical No. - 27 28 Practical No. -28 29 Practical No. -29 30 Practical No. -30 31 Practical No. -31
  • 6. 6 Practical No-1 Date: 27/12/2021 Problem- Create a database 'csfile' on the database server, show the list of databases and open it. Solution : > create database csfile; > show databases; > use csfile; Command and output ( Screenshot ) :
  • 7. 7 Practical No-2 Date: 27/12/2021 Problem- Create the following table named 'Dept' and 'Emp' with appropriate data type, size and constraint(s). Show its table structure also. Solution : create table dept(deptno int(2) primary key, dname varchar(10), Location varchar(15)); Table structure: Command : desc dept; create table Emp(Empno int(4) primary key, Ename varchar(15) not null, Job varchar(10), MGR int(4), Hiredate date, Sal double(8,2) check (sal>10000), Comm double(7,2), Deptno int(2) references Dept(deptno));
  • 8. 8 Practical No-3 Date: 27/12/2021 Problem- insert few records/tuples into the table. Verify the entered records. Solution : insert into dept values(10, 'Accounts', 'Delhi'); Note : issued similar commands for other records.
  • 9. 9
  • 10. 10 Practical No-4 Date: 28/12/2021 Problem- Display all the information of employees whose job is NEITHER Manager nor Clerk. Solution- select * from emp where job not in ('Manager', 'Clerk');
  • 11. 11 Practical No-5 Date: 28/12/2021 Problem- Display the details of all the employees whose Hiredate is after December 1991. (consider the Sql’s standard date format) Solution: select * from student where Hiredate>'1991-12-31'; Practical No-6 Date: 28/12/2021 Problem- Display the details of all the employees whose Hiredate is maximum. (consider the Sql’s standard date format) Solution: select * from emp where Hiredate=(select max(hiredate) from emp);
  • 12. 12 Practical No-7 Date: 29/12/2021 Problem- Display all information of Clerk and Manager in descending salary wise. Solution: select * from emp where job in('Clerk','Manager') order by sal desc; OR select * from emp where job ='Clerk' or job='Manager' order by sal desc;
  • 13. 13 Practical No-8 Date: 29/12/2021 Problem-Display all columns arranged in descending order of Job and within the Job in the ascending order their Names. Solution: select * from emp order by Job desc, Sal;
  • 14. 14 Practical No-9 Date: 10/01/2022 Problem- List all employees whose name has the character ‘a’. Solution: Select * from emp where Ename like '%a%';
  • 15. 15 Practical No-10 Date: 10/01/2022 Problem- Display Name and Salary of those Employees whose Salary is in the range 40000 and 100000 ( both are inclusive) Solution: select EName, Sal from Emp where Sal between 40000 and 100000;
  • 16. 16 Practical No-11 Date: 11/01/2022 Problem- Display those records whose commission is nothing. Solution: select * from emp where Comm is null;
  • 17. 17 Practical No-12 Date: 11/01/2022 Problem- Display average Salary, highest Salary and total no. of Employees for each department. Solution: Select deptno, avg(Sal), Max(Sal), Count(*), from Emp group by deptno; Practical No-13 Date: 11/01/2022 Problem- Display total no of Clerk, Manager, Analyst, Salesman and Salesman along with their average Salary. Solution: Select Job, count(*), avg(Sal) from Emp group by Job;
  • 18. 18 Practical No-14 Date: 12/01/2022 Problem- Increase the Salary of 'Clerk' by 5% Sal and verify the updated rows. Solution: update Emp set Sal=Sal+(Sal*0.05) where Job = 'Clerk';
  • 19. 19 Practical No-15 Date: 12/01/2022 Problem- Add a new column named Address. ( Take the data type and size yourself) and verify the table structure. Solution: Alter table Emp add address varchar(25); Practical No-16 Date: 12/01/2022 Problem- Delete the column Address and verify the table structure. Solution: Alter table Emp drop column Address;
  • 20. 20 Practical No-17 Date: 13/01/2022 Problem- Display Ename, job, salary and Hiredate of 'Analysts' whose Salary is below 65000 Solution: Select EName, Job, Salary, Hiredate from Emp where Job='Analyst' and Sal<65000; Practical No-18 Date: 13/01/2022 Problem- Display unique Jobs. Solution: Select distinct Job from Emp;
  • 21. 21 Practical No-19 Date: 13/01/2022 Problem- Display Job and highest Salary of Employee of each type of Job, but only for Clerk and Manager. Solution: Select Job, max(Sal) from Emp group by Job having Job in('Clerk','Manager'); Practical No-20 Date: 14/01/2022 Problem- Display Job and highest Salary of Employee of each type of Job, but only for Clerk, Manager and Analyst arranged in ascending order of job. Solution: Select Job, max(Sal) from Emp group by Job having Job in('Clerk','Manager','Analyst') order by job;
  • 22. 22 Practical No-21 Date: 14/01/2022 Problem- Find the Cartesian product of both the tables, Emp and Dept. Solution: Select * from emp cross join Dept;
  • 23. 23
  • 24. 24 Practical No-22 Date: 14/01/2022 Problem- Write a query to display corresponding information from both the tables using equi-join. Solution: Select * from emp, dept where emp.deptno=dept.deptno;
  • 25. 25 Practical No-23 Date: 14/01/2022 Problem- Write a query to display Ename, Job and Salary from Emp and its corresponding Dname and Location from Dept tables using equi-join. Solution: Select Ename, Job, Sal, Dname,Location from emp, dept where emp.deptno=dept.deptno;
  • 26. 26 Practical No-24 Date: 14/01/2022 Problem- Write a query to display corresponding information from both the tables using natural join. Solution: Select * from emp natural join dept;
  • 27. 27 Practical No-25 Date: 14/01/2022 Problem- Write a query to display corresponding information from both the tables using natural join. Solution: Select * from emp natural join dept order by Ename;
  • 29. 29 Practical No-26 (STACK) Date: 15/01/2022 Problem : Write a program to show push and pop operation using stack. Solution: #stack.py def push(stack,x): #function to add element at the end of list stack.append(x) def pop(stack): #function to remove last element from list n = len(stack) if(n<=0): print("Sorry! Stack empty......") else: num=stack.pop() print(num, "is popped out..") def display(stack): #function to display stack entry if len(stack)<=0: print("Sorry! Stack empty.....") for i in stack: print(i,end=" ") #main program starts from here x=[] choice=0 while (choice!=4): print("n********STACK Menu***********") print("1. push(INSERTION)") print("2. pop(DELETION)") print("3. Display ") print("4. Exit") choice = int(input("Enter your choice :")) if(choice==1): ans='y' while ans.upper()=='Y': value = int(input("Enter a value ")) push(x,value) ans=input('Push more(y/n):') if ans.upper()=='N':
  • 31. 31
  • 32. 32
  • 33. 33
  • 34. 34 Practical No-27 (PYTHON CONNECTIVITY) Date: 16/01/2022 Problem : Write a Program to show MySQL database connectivity in python. PROGRAM: import mysql.connector as conn mydb=conn.connect(host="localhost",user="root",passwd="tiger",database="csfile") # create new cursor cur=mydb.cursor() qry1="select * from emp" cur.execute(qry1) data=cur.fetchall() print(data) OUTPUT:
  • 35. 35 Practical No-28 (PYTHON CONNECTIVITY) Date: 17/01/2022 Problem : Write a Program to show how to retrieve records from a database table Emp using MySQL database connectivity in python. PROGRAM: import mysql.connector as conn try: mydb=conn.connect(host="localhost",user="root",passwd="tiger",database="csfile") # create new cursor cur=mydb.cursor() qry1="select * from emp" cur.execute(qry1) data=cur.fetchall() print ("EmpNo Emp Name Job MgrNO Hiredate Salary Commission DeptNo") print("-"*80) for cols in data: eno = cols[0] enm = cols[1] jb =cols[2] mg=cols[3] hdt=cols[4] sl=cols[5] com=cols[6] dpt=cols[7] print (eno,enm,jb,mg,hdt,sl,com,dpt) print("-"*80) except: print ("Error: unable to fecth data") mydb.close()
  • 37. 37 Practical No-29 (PYTHON CONNECTIVITY) Date: 18/01/2022 Problem : Write a Program to show how to add records in a database table Emp using MySQL database connectivity in python. PROGRAM: import mysql.connector as conn mydb=conn.connect(host="localhost",user="root",passwd="tiger",database="csfile") # create new cursor cur=mydb.cursor() eno=int(input("Enter Employee number : ")) enm=input('Enter Employee Name : ') jb=input("Enter Job: ") mg=int(input("Enter Manager No : ")) hdt=input("Enter Hiredate (yyyy-mm-dd) : ") sl=float(input('Enter Salary : ')) com=float(input('Enter Commission : ')) dpt=int(input("Enter Deptt. No : ")) sql="INSERT INTO emp VALUES ('%d', '%s' ,'%s','%d','%s','%f','%f','%d')" %(eno,enm, jb,mg,hdt, sl,com, dpt) try: cur.execute(sql) print("One row entered successfully...") mydb.commit() except: mydb.rollback() mydb.close() OUTPUT:
  • 38. 38 Practical No-30 (PYTHON CONNECTIVITY) Date: 19/01/2022 Problem : Write a Program to show how to update a record in a database table Emp using MySQL database connectivity in python. PROGRAM: import mysql.connector as conn mydb=conn.connect(host="localhost",user="root",passwd="tiger",database="csfile") # create new cursor cur=mydb.cursor() eno=int(input("Enter Employee number : ")) sl=float(input('Enter Salary : ')) sql="update emp set sal=%f where empno=%d" % (sl,eno) try: ans=input("Are you sure you want to update the record : ") if ans=='y' or ans=='Y': cur.execute(sql) print("Emp no-",eno," salary updated successfully...") mydb.commit() except Exception as e: print("Error! Perhaps Emp no is incorrect...",e) mydb.rollback() mydb.close() OUTPUT:
  • 39. 39 Practical No-31 (PYTHON CONNECTIVITY) Date: 20/01/2022 Problem : Write a Program to show how to DELETE a record from a database table Emp using MySQL database connectivity in python. PROGRAM: import mysql.connector as conn mydb=conn.connect(host="localhost",user="root",passwd="tiger",database="csfile") # create new cursor cur=mydb.cursor() eno=int(input("Enter Employee number : ")) sql="delete from emp where empno=%d" % (eno) try: ans=input("Are you sure you want to delete the record : ") if ans=='y' or ans=='Y': cur.execute(sql) print("Emp no-",eno," record deleted successfully...") mydb.commit() except Exception as e: print("Error! Perhaps Emp no is incorrect...",e) mydb.rollback() mydb.close() OUTPUT: Teacher's Signature: _____________________