You are on page 1of 53

INFORMATICS

PRACTICES (065)

RECORD OF PRACTICAL WORK

NAME :

STD :

SCHOOL : BVM, EROOR


INDEX
Sl. No. PROGRAM
1. Series – Student Data
2. Series – State and Area
3. Series – Employee Data
4. Series – Details of Unemployment Rate
5. DataFrame – Quarterly Sales
6. DataFrame – Cricketers Data
7. DataFrame – Examination Data
8. DataFrame – Examination Data
9. DataFrame – Employee Data
10. DataFrame – Software Project Data
11. DataFrame – Details of Literacy Rate
12. DataFrame – Details of Literacy Rate
13. DataFrame and CSV File – Employee Data
14. DataFrame and CSV File – Student Data
15. Data Visualization – Unemployment Data Analysis
16. Data Visualization – Student data
17. Data Visualization – Student data
18. Data Visualization – Temperature Analysis
19. Data Visualization – Employee Data
20. MySQL – Revision Exercises
21. MySQL – Single Row Functions
22. MySQL – Group Functions
PROGRAM 1
Write a Python program to accept the name and marks(out of 100) of n students and store it as a
Series with the name as index and marks as value.
a) Display the details of all students
b) Display the details of students along with status PASS or REFERRED. A student has to secure
40 marks to pass .

PROGRAM CODE

INPUT

OUTPUT
PROGRAM 2
Write a Python program to create a series that stores the State name as index and it’sarea in Km2of
following south Indian states as values.

State Area in km2


Andhra Pradesh 160205
Karnataka 191791
Kerala 38863
Odisha 155707
Tamil Nadu 130058
Telangana 112077
Write the code to :
a) Display the states with area more than 125000km2.
b) Display the details of first two states in the series
c) Display the details of last two states in the series
d) Display the names of the states.

PROGRAM CODE
OUTPUT
PROGRAM 3
Write a Python program to accept the salary of 5 employees for the current month and store it in a
Series S1 with name of employee as the index and salary as value. Another Series S2 stores the
bonus earned by each employee. Calculate the net salary earned by each employee. Display the
details of employees who have a net salary of more than 35000.

PROGRAM CODE
INPUT

OUTPUT
PROGRAM 4

Write a Python program to create a series using lists to store the year and unemployment rate as
percentage for 6 years.
a) Calculate and display those years where unemployment rate is above 15 percentage.
b) Display the unemployment rate of year 2014 and 2015
c) Display the unemployment rate of year 2018 and 2019
d) Display the unemployment rate of year 2016 and 2017
e) Display the unemployment rate of year 2015 and 2018
Sample Data

Year 2014 2015 2016 2017 2018 2019


Unemployment Rate 18 17 19 14 14 16
OUTPUT
PROGRAM 5
Write a Python program to create a DataFrame to store the quarterly sales of the past 3 yearsas
given below and also write code to :
a) Display the data from Dataframe
b) Display the details of year 2018
c) Display the details of Qtr1, Qtr2
d) Display the details of year 2017 and 2019
e) Display the details of Qtr2 in the year 2018

2017 2018 2019


Qtr1 34500 44900 54500
Qtr2 36000 46100 51000
Qtr3 47000 57000 58500
Qtr4 48000 59000 60000
OUTPUT
PROGRAM 6
Write a Python program to create a DataFrame consisting of columnsto store name, age and score
of following cricketers and perform following operations on the Dataframe.

a) Display the details of Dataframe.


b) Display the Name and Scores of all Cricketers
c) Display the details of crickets whose age is 30 or above.
d) Display the score of Rohit Sharma
e) Display the name and age of all players who have scored less 1000 runs.

Player Age Score


Shikhar Dhawan 33 5355
Rohit Sharma 32 8010
K. L. Rahul 27 343
Virat Kohli 30 10843
OUTPUT
PROGRAM 7
Write a Python program to create a DataFrame to accept and store Name , Accountancymarks
and IP marks(out of 100) for n students. Roll Number will be the row index. Also write the
code to :
a) Display the data stored in Dataframe
b) Display the marks scored in Accountancy for all students
c) Display the IP marks of those students who scored more than 75

PROGRAM CODE
INPUT

OUTPUT
PROGRAM 8
Write a Python program to create a DataFrame to accept and store Name , Accountancymarks
and IP marks(out of 100) for n students. Roll Number will be the row index. Also write the
code to :

a) Add a column average to store the average of Accountancy and IP marks.


b) Display those students details whose IP marks is more than average marks.

PROGRAM CODE
INPUT

OUTPUT
PROGRAM 9
Create a Data frame to store the following salary details of employees in an
organization.
Employee Details -> Name, Basic, HRA

Name Basic HRA


Shankar 25000 12000
Thejus 30000 10000
Susan 20000 9000
Trisha 25000 10000
Mridul 20000 10000
Also calculate and display
Total Salary = Basic+HRA
Each employee’s PF is calculated as 9% of his Total salary.Calculate
Allowance based on the following :
Total Salary Allowance
>=35000 5% of Total Salary
<35000 and >=25000 7% of Total Salary
<25000 10%. of Total Salary
Net Salary=(Total Salary + Allowance) – PF

PROGRAM CODE
OUTPUT
PROGRAM 10
Given the DataFrame DF to store the project details of a software organisation.

Write a program to create the DataFrame given above and


1. To display the details of employees having age greater than 30
2. Change the label of 2nd column to Designation and 4th column to Number of Projects.
3. Add row labels as ‘e1’,’e2’,’e3’,’e4’
4. Add a row with the following details Sangeet, ‘Analyst’, 38, 23
5. Include a column Qualification with appropriate values.

PROGRAM CODE
OUTPUT
PROGRAM 11

Write a program to create a DataFrame state for storing the Literacy rate of 5 statesgiven below.
Use StNo data as row index.
StNo State Name 1981 1991 2001 2011
28 Andhra Pradesh 35.7 44.1 60.5 67.7
29 Karnataka 46.2 56.0 66.6 75.6
33 Tamil Nadu 54.4 62.7 73.5 80.3
27 Maharashtra 57.2 64.9 76.9 82.9
32 Kerala 78.9 89.8 90.9 93.9
Display the Dataframe and write code to perform the following :
a) Display the literacy rates in 2011
b) Display the literacy data of Tamil Nadu
c) Display the row labels of dataframe
d) Display the column labels of dataframe

PROGRAM CODE
OUTPUT
PROGRAM 12

Write a program to create a DataFrame state for storing the Literacy rate of 5 statesgiven below.
Use StNo data as row index.
StNo State Name 1981 1991 2001 2011
28 Andhra Pradesh 35.7 44.1 60.5 67.7
29 Karnataka 46.2 56.0 66.6 75.6
33 Tamil Nadu 54.4 62.7 73.5 80.3
27 Maharashtra 57.2 64.9 76.9 82.9
32 Kerala 78.9 89.8 90.9 93.9
Display the Dataframe and write code to perform the following :
a) Display the datatype of dataframe
b) Display the data type of each column in dataframe
c) Display the dimension of dataframe
d) Display the number of elements in the dataframe

PROGRAM CODE
OUTPUT
PROGRAM 13
Write a python program to
i) Accept the following employee details (EmployeeNo, Name, Salary) and store them in a
DataFrame df.
ii) Export the data from DataFrame and store it in a csv file(employee.csv).
iii) Read data from the csv file and display the content .

PROGRAM CODE

INPUT

OUTPUT
PROGRAM 14

Write a python program to


a. Accept the following student details (RollNo, Name, Marks) and store them ina DataFrame
df.
ii) Export the data from DataFrame and store it in a csv file(Student.csv).
iii) Display the student details stored in the CSV file Student.csv by importing it into a new
DataFrame.
iv) Display the grade for each student based on the marks scored.

Marks Grade
>=90 A
>=75 B
>=50 C
< 50 Referred

PROGRAM CODE
INPUT

OUTPUT
PROGRAM 15

The Unemployment rates of 6 years are stored in a series. Draw a line graph to displaythe data. Give
appropriate title and labels.

Year 2014 2015 2016 2017 2018 2019


Unemployment Rate 18 17 19 14 14 16

PROGRAM CODE
OUTPUT
PROGRAM 16

Create a DataFrame to store the IP marks secured by 5 students in Term1 Examinations in Term
2examinations. Perform the following operations on the Dataframes.
1. Create a column total marks to store total marks secured in both exams.
2. Display the details of students who have scored a total of more than 170.
3. Draw a line graph to display the total marks of student scored by each student.

Term 1 IP Term 2 IP
Name
Marks Marks
Athul 90 85
Divya 85 80
Irene 89 80
Karthik 80 80
Manya 95 90

PROGRAM CODE
OUTPUT
PROGRAM 17

The Marks scored by 5 students in 2 subjects(out of 100) and store it in a Dataframe. Analyse the
subject wise performance of students using a Line chart.

SName EngMark IPMark


Ajay 85 82
Brinda 75 79
Haritha 91 95
Manoj 92 98
Umesh 80 90
PROGRAM CODE
OUTPUT
PROGRAM 18

The average temperature(in Celsius) of seven days in a week is stored in a Series. Analyse
thetemperature variation using a Bar chart.
wday- Mon, Tue, Wed, Thu, Fri, Sat, Sun
avgtmp=34,32,30,34,29,31,33

PROGRAM CODE

OUTPUT
PROGRAM 19
Create a DataFrame to store the following Employees Code and Age of employees. Draw
Histogramsto perform a comparative analysis of this data.
ECode – 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
Age – 25,23,25,30,25,30,28,35,21,29,32,35,26,20,29

PROGRAM CODE

38
OUTPUT

39
‘TechIndia’ is a software development firm. Create a database TechIndia. In the
database create a table Employee with the given structure to store the details of its
employees. Enter the data given.
DATABASE : TechIndia
TABLE : Employee
Field Name Type Size Constraint
EmpID Char 4 Primary Key
EName Varchar 25 Not NULL
Gender Char 1 M or F
Dob Date
Department Char 4
Grade Char 2
Salary Integer 6

1. Create a database TechIndia.


Create database TechIndia;

2. Open the database TechIndia


Use TechIndia;

3. Create a table Employee using the above structure.


Create table Employee ( EmpID char(4) PRIMARY KEY, EName varchar(25) NOT
NULL, Gender char(1) check (Gender ='M' or Gender='F'), Dob date, Department
char(4) , Grade char(2), Salary int(5));

4. Display the structure of table Employee.


Describe Employee;

5. Add the above records


Insert into Employee values ('E101', 'Adithya', 'M','1992/02/12','ACCT','E1', 45000);
40
6. Display all the records.
Select * from Employee;

7. Display the details of employees in IT department.


Select * from Employee where department =’IT’;

8. Display the Name and salary of female employees.


Select EName, Salary from Employee where Gender=’F’;

9. Display the Name, Gender and Date of birth of all employees earning salary less than
40000.
Select EName, Gender, Dob from Employee where Salary <40000;

10.Display the Name of employees as ‘Employee Name’ and Salary who earn salary
between 20000 and 35000.
Select EName ‘Employee Name’, Salary from Employee where Salary between
20000 and 35000;

Select EName ‘Employee Name’, Salary from Employee where Salary >=20000 and
Salary <= 35000;

11.Display the details of employees in grade E1 and E3 .


Select * from Employee where Grade in (‘E1’, ‘E2’);

Select * from Employee where Grade=’E1’ and Grade=’E2’;

12.Display the Name, gender and salary of employees in the descending order of their
salary
Select EName, Gender, Salary from Employee order by Salary desc;

13.Display the Name and Department of employees in the ascending of name within
department.
Select EName, Department from Employee order by Department, Name;

14.Display the details of employees whose name ends with ‘a’.


Select * from Employee where EName like ‘%a’;

15.Display name and department of employees whose name has ‘u’ as second alphabet.
Select EName, Department from Employee where EName like ‘_u%’

16. Add the details of a new employee as given


E111, Sangamitra, F, 1997-08-26, HRD, E2, 30000

41
Insert into Employee values (‘E111’, ‘Sangamitra’, ‘F’, ‘1997-08-26’, ‘HRD’, ‘E2’,
30000);

17. Change the grade of Employee with id E111 to E3.


Update Employee set Grade=’E3’ where EmpId=’E111’;

18.Delete the details of Sangamitra.


Delete from Employee where EName=’Sangamitra’;

19. Add a column city.


Alter table Employee add city varchar(20);

20.Delete the column city


Alter table Employee drop city;

21.Create table Book and add the records

Create table Book(AccNo int(4) PRIMARY KEY, Bname varchar(30) NOT NULL,
Author varchar(30) NOT NULL, Price int(4), DOP date, Category char(1) check
(Category in ‘A’ ,’B’,’C’,’D’,’E’,’O’));

Describe Book;

Insert into Book values (2435, ‘Rich Dad Poor Dad’, ‘Robert T Kiyosaki’,
‘2007/02/15’, ‘B’);

Select * from Book;

42
MySQL – Single Row Functions
Exercise 1

Create database XIIEIP;

Use XIIEIP;

Create table Book(AccNo int(4) PRIMARY KEY, Bname varchar(30) NOT NULL,
Author varchar(30) NOT NULL, Price int(4), DOP date, Category char(1) check
(Category in ‘A’ ,’B’,’C’,’D’,’E’,’O’));

Describe Book;

Insert into Book values (2435, ‘Rich Dad Poor Dad’, ‘Robert T Kiyosaki’,
‘2007/02/15’, ‘B’);

Select * from Book;

Write the SQL command for the following:

1. Display the name of books in capital letters which belong to Category B.

43
2. Display the name of book in capital letters and author’s name in small letter of
books which cost more than 300.

3. Display the number of characters in each book name along with book name for
book with accession number 2435,2478 and 2604.

4. Display the name of the book and the first letter of each book name belonging to
category A.

5. Display the position of first occurrence of o in author’s name of book written by


author whose name ends with i.

6. Display the 3rd, 4th and 5th character of each book name in category C.

44
7. Display the last 3 character of author name of book with accession number more
than 2600 in descending order of accession number.

8. Display the first and last alphabet of author’s name of author’s who have written
books with book name which contains word ‘of’

9. Display the month name of purchase of books in category C.

10.Display the names of books purchased in December along with their price.

45
11.Display the book details of books purchased in April 2006.

12.Display the books with even accession number.

13.Display the details of books purchased in or before 2006.

14.Display the book name and price of books purchased on Tuesday.

15.Display the name and date of purchase of books which are 14 years old.
46
16.Display the name and date of purchase of books purchased on 5th of a month.

17.Display the length of book names raised to the power of 2 for books in category
A, along with the book names.

18.Display the square root of accession number of books along with book name and
author whose author name is more than 25 characters long.

19.Display the month and year of purchase of book along with book name whose
price is not available.

47
20.Display the dayname and month of purchase of all books along with book name of
books which cost more than 300.

-------------------------

48
MySQL - Group Functions
Exercise 2.
‘TechIndia’ is a software development firm. Create a database TechIndia. In the
database create a table Employee with the given structure to store the details of its
employees. Enter the data given.
DATABASE : TechIndia
TABLE : Employee
Field Name Type Size Constraint
EmpID Char 4 Primary Key
EName Varchar 25 Not NULL
Gender Char 1 M or F
Dob Date
Department Char 4 Can take any one value - ACCT, HRD,
IT
Grade Char 2 Can take any one value -E1, E2, E3
Salary Integer 6

Create database TechIndia;

Use TechIndia;

Create table Employee ( EmpID char(4) PRIMARY KEY, EName varchar(25) NOT
NULL, Gender char(1) check (Gender ='M' or Gender='F'), Dob date, Department
char(4) check (Department in ('ACCT', 'HRD', 'IT')) , Grade char(2) check (grade in
('E1', 'E2','E3')), Salary int(5));

Describe Employee;

Insert into Employee values ('E101', 'Adithya', 'M','1992/02/12','ACCT','E1', 45000);

Select * from Employee;

49
Write the SQL commands for the following :
1. Display the total number of Employees in the organisation.

2. Display the number of employees in each department.

3. Display the number of employees in each grade with in each department.

4. Display the total number of Male and total number of Female staff working in the
organisation.

5. Display the total salary earned by Employees in the organisation.

50
6. Display the total salary earned by Male and total salary earned by Female staff of IT
Department.

7. Display the total salary of those departments whose total salary is more than one
lakh.

8. Display the average salary earned by employees in each grade.

9. Display the average salary earned by male and female employees within each
department.

10.Display the average salary earned by employees in the accounts department.

11.Display the average salary of employees in each grade, if the average salary is more
than 30000.

51
12.Display the maximum salary earned by the employees.

13.Display the maximum salary earned by Female employees

14.Display the maximum salary earned in each department.

15.Display the minimum salary earned by employees in each grade.

52
16.Display the minimum salary earned by male employees and minimum salary earned
by female employees.

17.Display the total salary of employees in each grade, where the number of employees
in each grade is more than or equal to 5.

18.Display the number of employees who earn less than 30000.

19. Display the number of female employees in HRD department who earn more than
35000.

20.Display the number of employees whose names end with ‘a’.

-----------------------
53

You might also like