0% found this document useful (0 votes)
8 views10 pages

SET 1 Part A Marks, (

The document contains a series of programming tasks and SQL commands for students in Class XII at Sri Chaitanya Educational Institutions, Karnataka, focusing on Python and SQL. It includes creating and manipulating DataFrames, generating charts, and performing database operations such as creating tables and inserting data. Each section is divided into parts A, B, and C, with specific coding and database tasks to complete.

Uploaded by

ujjwalenosh
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
0% found this document useful (0 votes)
8 views10 pages

SET 1 Part A Marks, (

The document contains a series of programming tasks and SQL commands for students in Class XII at Sri Chaitanya Educational Institutions, Karnataka, focusing on Python and SQL. It includes creating and manipulating DataFrames, generating charts, and performing database operations such as creating tables and inserting data. Each section is divided into parts A, B, and C, with specific coding and database tasks to complete.

Uploaded by

ujjwalenosh
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/ 10

Sri Chaitanya Educational Institutions, Karnataka

Class: XII Sub: Informatics Practices (065)

im

SET 1 Part A
1. Write python code for the following with respect to DataFrame marks, (3M)

(i) Write the code to create dataframe


marks

(ii) Display first two rows.


(ii) Add a new column called Total which is sum of all Tests.
Ans}
import pandas as pd
k=[{'test1':45,'test2':58,'test3':47,'test4':65},
{'test1':36,'test2':85,'test3':44,'test4':46},
{'test1':78,'test2':96,'test3':88,'test4':77},
{'test1':54,'test2':50,'test3':74,'test4':85}]
print(k)
Marks=pd.DataFrame(k,index=['Ram','Peter','Alex','John'])
print(Marks)

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

P.ID P.Name Category Stock Comm Mfgdate


1 Phone Electronics 30 500.56 '2024-09-27'
2 Shoe Apparel 50 600.56 '2023-10-15')
3 Chair Home 45 800.96 '2023-10-15'
4 TV Electronics 100 242.56 2023-09-21
5 Mobile Electronics 1000 400.85 '2023-10-19'

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

ii. insert the data into the products table


P.ID P.Name Category Stock Comm Mfgdate
1 Phone Electronics 30 500.56 '2024-09-27'
2 Shoe Apparel 50 600.56 '2023-10-15')
3 Chair Home 45 800.96 '2023-10-15'
4 TV Electronics 100 242.56 2023-09-21
5 Mobile Electronics 1000 400.85 '2023-10-19'

iii. Display first two characters in every


product name
iv. Display product name by deleting leading/trailing spaces if there are any v.
Display the position of ‘nic’ in product category
vi. Display product names and category manufactured in October month vii.
Display all products manufactured month name

SET 4
Part A

1. write python code to create the following DataFrame (3M)

(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']

(iii) Delete a column called Dept.

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)

Ans) mysql> create table students(Rollno int primary key,Name varchar(20),dob


date,city varchar(16),Stream varchar(10),Fee decimal(6,2));

ii. insert the data into the students table


Roll.no Name Dob City Stream Fee
1. srinath 2015-11-05 Bangalore Science 20000
2. Supriya 2016-09-25 Nagpur Humanities 30000
3. Chandhan 2018-12-18 Delhi Science 25000
4. John 2015-10-21 Nagpur Arts 21000

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);

iii. Display all student names

Iv Display Humanities student details who are coming from Nagpur.

V Display student names whose fee is in between 2000 to 3000 (including


both).

vi. Display all student details whose name starts with s

vii. Display student names as per ascending order of their fee.

Page 10 of 10

You might also like