100% found this document useful (1 vote)
4K views

Practical Examination 2020 Ip Set 1

The document contains instructions for a practical examination in Informatics Practices involving Python Pandas and Data Visualization. It includes questions to create a dataframe from employee data, add/modify columns and rows, filter data, and plot a bar chart of salaries. The student is asked to write Python code to perform the given tasks on the dataframe and answer SQL queries on an equivalent database table. Marks are allotted for the Python program, practical file submission, project file, and viva voice.

Uploaded by

sofia gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
4K views

Practical Examination 2020 Ip Set 1

The document contains instructions for a practical examination in Informatics Practices involving Python Pandas and Data Visualization. It includes questions to create a dataframe from employee data, add/modify columns and rows, filter data, and plot a bar chart of salaries. The student is asked to write Python code to perform the given tasks on the dataframe and answer SQL queries on an equivalent database table. Marks are allotted for the Python program, practical file submission, project file, and viva voice.

Uploaded by

sofia gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

VISHWA HARATI PULIC SCHOOL ,NOIDA

SUBJECT: INFORMATICS PRACTICES(Code - 065)


PRACTICAL EXAMINATION 2021-22
MM-30 SUBJECT: INFORMATICS PRACTICES (065) TIME: 3 HOURS
SET-1

Q.NO Python Pandas and Data Visualization Marks


.
Q.1- Write a program in python to create the following dataframe named “emp” storing the details of 2
employees:
ename job salary dojoin department
1001 Scott Manager 90000 2010-10-01 Accounts
1002 Tom Clerk 34000 2010-01-04 Admin
1003 Joy Clerk 32000 2009-03-01 Admin
1004 Sam Salesman 40000 2009-04-01 Sales
1005 Martin Manager 85000 2008-08-05 Sales
1006 Michel Salesman 43000 2008-08-06 Sales
1007 Francis Clerk 30000 2009-10-10 Accounts
Considering the above dataframe answer the following queries by writing appropriate command
in python pandas.
a) Add a new column named bonus ( just after salary column) which is 15% of their salary. ½
b)Add a row with row index 1008 as Robin,Analyst,60000,9000,2011-04-01,Admin. ½
c) Now change the salary of Francis as 35000. ½
d) Display the details of Sales and Accounts department . ½
e) Display the employee name, job and salary for all those employees whose salary lies between ½
30000 and 50000.
f) Delete a column dojoin permanently. ½
g) display the max ,min ,mode of salary. 3

8
Total =
SQL Queries with Solution
Q.2- Consider the above table as "emp" and first column is 'empno' as primary key. Answer the 1x7=7
following sql queries.
a) Add a row with empno 1008 as Robin,Analyst,60000,2011-04-01,Admin.
Insert into emp values(1008,'Robin','Analyst',60000,'2011-04-01','Admin');
b) Display the detail of all employees whose salary lies in the range 50000 and 100000.
Select * from emp where salary between 50000 and 100000;
c) Display average salary and no. of employees of each department.
Select department, avg(salary), count(*) from emp group by department;
d) Display maximum salary of each type of job for Clerk and Manager only.
Select job,max(salary) from emp group by job having job in ('Clerk','Manager');
e) increase the salary of sales department employees by 5 percent.
Update emp set salary=salary+salary*0.05 where department='Sales';
f) Delete the column dojoin.
Alter table emp drop column dojoin;
g) Display detail of employees in descending order of their salary.
Select * from emp order by salary desc;

Practical File 5
Project File 5
Viva Voice 5
Solution: Q.1- Program Code:
import pandas as pd
import matplotlib.pyplot as plt
dict1={'ename':['Scott','Tom','Joy','Sam','Martin','Michel','Francis'],
'job':['Manager','Clerk','Clerk','Salesman','Manager','Salesman','Clerk'],
'salary':[90000,34000,32000,40000,85000,43000,30000],
'dojoin':['2010-10-01','2010-01-04','2009-03-01','2009-04-01','2008-08-05','2008-08-06','2009-10-10'],
'department':['Accounts','Admin','Admin','Sales','Sales','Sales','Accounts']}
emp=pd.DataFrame(dict1,index=[1001,1002,1003,1004,1005,1006,1007])
print(emp)

x=emp['salary']*0.15
# Add a new column named Bonus ( just after salary column) which is 15% of their salary.
emp.insert(3,'bonus',value=x)
print(emp)

# Add a row with row index 1008 as Robin,Analyst,60000,2011-04-01,Admin.


emp.loc[1008]=['Robin','Analyst',60000,9000,'2011-04-01','Admin']
print(emp)

# Now change the salary of Francis as 35000.


emp.loc[(emp.ename=='Francis'),'salary']=35000
print(emp)

#Display the details of Sales and Accounts department


print(emp.loc[(emp.department=='Accounts') | (emp.department=='Sales')])
# Display the employee name, job and salary for all those employees whose
# salary lies between 30000 and 50000.
print(emp.loc[(emp.salary>=30000) & (emp.salary<=50000),['ename','job','salary']])

# Delete a column dojoin permanently.


emp.drop('dojoin',axis=1,inplace=True)
print(emp)

#Now plot a bar chart depicting the employee name on x-axis and their corresponding
#salary on y-axis, with appropriate Graph title, x-axis title, y-axis title,
#gridlines and color etc.
x=emp['ename']
y=emp['salary']
plt.bar(x,y,color='r')
plt.xlabel('Name-->',fontsize=12,color='g')
plt.ylabel('Salary (Rs.)-->',fontsize=12,color='g')
plt.title('ABC PVT Limited\n Employees Salary analysis', fontsize=14, color='r')
plt.grid()
plt.show()
OUTPUT:

You might also like