SET 1 Part A Marks, (
SET 1 Part A Marks, (
im
SET 1 Part A
1. Write python code for the following with respect to DataFrame marks, (3M)
print(Marks.head(3))
Marks['Total']=Marks['test1']+Marks['test2']+Marks['test3']+Marks['test4']
print(Marks)
Part B
2. Write program in python to create a line chart with the given data and
also set the name to . x-axis as ename, y axis as sal, title as simple. Also save
graph as simple.pdf
Page 1 of 10
Sri Chaitanya Educational Institutions, Karnataka
Class: XII Sub: Informatics Practices (065)
ename=[‘Hari’,’Riya’,’Chandhan’,’Joe’,’Mita’]
sal=[4000,6000,5000,3500,8000]
Anus)
import matplotlib.pyplot as plt
ename=['Hari','Riya','Chandhan','Joe','Mita']
sal=[4000,6000,5000,3500,8000]
plt.plot(ename,sal)
plt.xlabel('employee name')
plt.ylabel('salary')
plt.title('EMPLOYEE SALARY DETAILS')
plt.savefig('Simple.pdf')
plt.show()
Part C
3. Write a SQL Command to do the following (7M)
i. create a table called products based on the following given data.
Columns/Field Datatype Key
Pid Int Primary key
Pname Varchar(20)
Category Varchar(15)
Stock Int
Comm Decimal(6,2)
Mfgdate date
ii. insert the following data into the products table as
iii. Display product name by deleting leading/trailing spaces if there are any iv.
Display the product details which has no commission. v. Display total
price of each category. vi. Display all products manufactured month name
vii. Display last two characters of every product name.
Page 2 of 10
Sri Chaitanya Educational Institutions, Karnataka
Class: XII Sub: Informatics Practices (065)
Page 3 of 10
SET 2 PART A
1. Consider the following Series Class and answer the questions.
A 45
B 36
C 27
D 35
(i) Write python code to create above series Class using list
(ii) Write a statement to delete element whose index is ‘B’
(iii) Write a statement to add one element with 54 as value and index as ‘E’
(3M)
import pandas as pd
Class=pd.Series([45,36,27,35],['A','B','C','D'])
print(Class)
del Class['B']
print(Class)
Class['E']=54
print(Class)
PART B
2. Write program in python to create a bar chart that represents boys and girls strength
of classes from 8 to 12, and also set the name to x-axis as class, y-axis as count and
title as 'Classs wise Boys and Girls count'. Also save graph as simple.pdf.
Class=[8,9,10,11,12]
Boys=[35,30,40,45,42]
Girls=[20,25,42,38,40]
ANS)
import matplotlib.pyplot as plt
import numpy as np
Class=[8,9,10,11,12]
Boys=[35,30,40,45,42]
Girls=[20,25,42,38,40]
dummy=np.arange(5)
plt.bar(dummy,Boys,label='Boys',width=0.4)
plt.bar(dummy+0.4,Girls,label='Girls',width=0.4)
plt.xlabel('Class')
plt.ylabel('Count')
Page 4 of 10
plt.title('Class wise Boys and Girls Count')
plt.savefig('simple.pdf')
plt.xticks(dummy,Class)
plt.legend(loc=2)
plt.show()
(5M)
PART C
3.Consider the following two tables Employee and Department, and write SQL commands
to the following (7M)
i. Create Department table as per above given data by applying primary key on
Deptno column ii. Create Employee table as per above given data by
applying primary on eno column and foreign key on deptno column with reference
to Department table deptno column
Insert data[40,cn,hari,][20,AI,shyam,][30,ML,Ananya] into Department table
iv. Insert data [1,riya,10,500][2,madhav,20,550][3,krish,20,400]into Employee
table
v. Display Employee and their Department name
vi. Display Employee and their HOD name who are working in CS department
vii. Display Employee and their department name whose hod is Riya
SET 3 PART A
3. Write python code to create the following DataFrame Stock (3M)
Page 5 of 10
(i) Write the code to create dataframe Stock (ii)
Add a new row with name as Diary with price 12.
(iii) delete row whose index is 4.
import pandas as pd
d={'Name':['Pen','Eraser','Pencil','Notebook'],'Price':[5,6,7,5]}
Stock=pd.DataFrame(d)
print(Stock)
Stock.loc[4]=['Diary',12]
print(Stock)
Stock.drop(4,axis=0,inplace=True)
print(Stock)
PART B
2.Write program in python to create a bar chart that represents boys and girls
strength of classes from 8 to 12, and also set the name to x-axis as class, y-axis as
count and title as 'Classs wise Boys and Girls count'. Also save graph as simple.pdf.
Class=[8,9,10,11,12]
Boys=[35,30,40,45,42] Girls=[20,25,42,38,40]
ANS)
import matplotlib.pyplot as plt
import numpy as np
Class=[8,9,10,11,12]
Boys=[35,30,40,45,42]
Girls=[20,25,42,38,40]
dummy=np.arange(5)
plt.bar(dummy,Boys,label='Boys',width=0.4)
plt.bar(dummy+0.4,Girls,label='Girls',width=0.4)
plt.xlabel('Class')
plt.ylabel('Count')
plt.title('Class wise Boys and Girls Count')
plt.savefig('simple.pdf')
plt.xticks(dummy,Class)
plt.legend(loc=2)
plt.show()
(5M)
Page 6 of 10
PART C
3. Write a SQL Command to do the following (7M)
i. create a table called products based on the following given data.
Columns/Field Datatype Key
Pid Int Primary key
Pname Varchar(20)
Category Varchar(15)
Stock Int
Comm Decimal(6,2)
Mfgdate date
SET 4
Part A
(i) Write python code to create the above following DataFrame emp ,?
Ans)
import pandas as pd d={'Name':
Page 7 of 10
['Anya','Smith','Bina','Vinay','Arjun'],'Job':
['Clerk','Analyst','Analyst','Clerk','Salesman'],
'Sal':[500,550,480,475,540]}
emp=pd.DataFrame(d)
print(emp)
(ii) Add a new column called Dept with values ['Maths','Phy','Chem','Comp','Phy']
Ans)
emp['Dept']=['Maths','Phy','Chem','Comp','Phy']
del emp[‘Dept’]
(or)
emp.drop([‘Dept’],axis=1,inpla
ce=True)
(or)
emp.drop(‘Dept’,axis=1,inplac
e=True)
(or)
emp=emp=emp.drop(‘Dept’,axis=1)
Part B
2. Write program in python to create a histogram that represents runs of batman in
different matches in the form of ranges, and also set the name to x-axis as runs range,
y-axis as runs and title as batsman score. Also save graph as simple.pdf,
runs=[81,85,65,42,57,72,85,99,94,72,66,67,76] bins=[50,60,70,80,90,100] (5M)
Ans:
import matplotlib.pyplot as plt runs=[81,85,65,42,57,72,85,99,94,72,66,67,76]
bins=[50,60,70,80,90,100]
plt.hist(runs,bins,rwidth=0.5)
plt.xlabel('Runs Range')
plt.ylabel('Runs')
plt.title('Batsman Score')
plt.savefig('simple.pdf')
plt.xticks(bins)
plt.show()
Page 8 of 10
Part C
3.Write SQL commands to do the following (7M)
i. Create the table students with following information.
Column Datatype Key
Rollno Int Primary Key
Name Varchar(20)
DOB Date
SCity Varchar(16)
Stream Varchar(10)
Fee Decimal(6,2)
Page 9 of 10
5. Kiran 2018-12-07 Mumbai Humanities 12000
Ans)
(1,'Srinath','2015-11-
05','Bangalore','Science',2344.75);
(2,'Supriya','2016-09-25','Nagpur','Humanities',5454.50);
(3,'Chandhan','2018-12-18','Delhi NCR','Arts',1234.56);
(4,'Giri','2012-12-12','Hyderabad','Science',8746.89);
(5,'Kaveri','2015-02-18','Chennai','Science',8746.89);
Page 10 of 10