GYAN GANGA
ENGLISH MEDIUM HIGH SCHOOL
CERTIFICATE
Abhishek Kushwaha
This is to certify that Ms/Mr. _________________________. Board
19
Roll Number ____________ Commerce [A]
student of class XII - ________________
from Gyan Ganga English Medium High School, has successfully
completed his practical work for academic session 2025 - 26 under my
supervision and guidance in partial fulfilment of SSCE Informatics
Practices (065) practical examination.
SIGN OF SIGN OF SIGN OF
INTERNAL EXAMINER PRINCIPAL EXTERNAL EXAMINER
SCHOOL SEAL
INTRODUCTION
Name : Abhishek Kushwaha
Class : XII - Commerce [A]
Subject : Informatics Practices (065)
School : Gyan Ganga English Medium High School
Submitted to : Mr. Arif Khan
ACKNOWLEDGEMENT
I would like to thank my teacher Mr. Arif Khan and principal sir
Mr. Sunil Nair for giving me the opportunity to do this practical
file. This also helped me in doing a lot of research and increased
my knowledge in difficult topics.
INDEX
Python Programming
Sr Page
Questions
No. Number
1. Create a panda's series from a dictionary of values and an ndarray. 1
2. Given a series, print all the elements that are more than 50000. 2
Create a Data Frame, quarterly sales, where each row contains the item category,
3. item name, and expenditure. Group the rows by the category and print the total 3
expenditure per category.
Create a data frame for examination result and display row labels, column labels data
4. types of each column and the dimensions. 4
5. Filter out rows based on different criteria such as duplicate rows. 5
6. Importing and exporting data between pandas and CSV file. 6
7. Locate the 3 largest values in a data frame. 7
8. Write a program to generate a series of 10 numbers with a scalar value of 44. 8
Read the 'Student_result.csv' to create a data frame and do the following operation:
9. a) To display Adm_No, Gender and Percentage from 'student_result.csv' file. 9
b) To display the first 5 and last 5 records from 'student_result.csv' file.
Create the following DataFrame Sales containing year wise sales figures for five
salespersons in INR. Use the years as column labels and salesperson names as row
labels.
10. Name/Sales 2018 2019 2020 2021 10 – 11
Megha 110 205 177 189
Karan 130 165 175 198
Dev 115 206 157 179
Radha 118 198 183 169
Consider above dataframe in previous question and write code to do the following:
11. a) Display the last two rows of Sales. 12
b) Display the first two columns of Sales.
Write a panda program to read marks detail of Manish and calculate sum of all
marks.
12. 13
#data = {'Manish': ['Physics', 'Chemistry', 'English', 'Maths', 'Informatics Practices'],
'marks': [89, 99, 97, 99, 98]}
13. Write a Pandas program to add, subtract, multiple and divide two Pandas Series. 14
Write a program to generate a series of 5 elements with the elements that are
14. multiple of 7. Start the series with the value 35. Also, multiply the index with 3. 15
Write a program to generate a series and print the top 5 elements using the head
15. 16
function
Write a program to generate a series of 10 numbers. Change the value of all the
16. elements to 21 those values are multiples of 4. 17
Given the school result data, analyses the performance of the students on different
17. parameters, e.g subject-wise or class-wise. 18
Take data of your interest from an open source (e.g. data.gov.in), aggregate and
18. summarise it. Then plot it using different plotting functions of the Matplotlib library. 19
Draw the histogram based on the Production of Wheat in different Years:
19. Year: 2000, 2002, 2004, 2006, 2008, 2010, 2012, 2014, 2016, 2018 20
Production: 4, 6, 7, 15, 24, 2, 19, 5, 16, 4
The table shows passenger car fuel rates in miles per gallon for several years. Make a
20. line graph of the data. During which 2-year period did the fuel rate decrease? 21
Year: 2000 2002 2004 2006 Rate: 21.0 20.7 21.2 21.6
The number of students in 7 different classes is given below. Represent this data on the bar
graph.
21. 22
Class 6 7 8 9 10 11 12
No. of Students 100 120 103 112 119 125 95
MySQL Programming
Sr Page
Questions
No. Number
Create a student table with the student_id, name, and marks as attributes where the
student_id is the primary key.
i. Insert the details of a new student in the above table.
ii. Delete the details of a student in the above table.
22. 23 – 24
iii. Use the select command to get the details of the students with marks
more than 420.
iv. Find the min, max, sum, and average of the marks in a student marks
table.
Find the total number of customers from each country in the table (customer ID,
23. customer Name, country) using group by. 25
Write a SQL query to order the (student ID, marks) table in descending order of the
24. marks 25
Write MySQL Command based on the table Product.
PCode PName Price Qty
P01 Adapter 350 20
P02 Cable 180 25
P03 Speaker 450 30
P04 Router 550 22
P05 Processor 10000 10
25. 26 – 27
i. To display the name of the entire product with price more than 300.
ii. To display the name of all the products by the quantity more than 25.
iii. To add a new row for product with the details : “P06”, “Monitor”, 3300, 15
iv. Display the product with highest price.
v. What are the total number of records in the table?
1. Create a panda's series from a dictionary of values and an ndarray.
Script:
import pandas as pd
import numpy as np
dic = {'A':22,'B':32,'C':45,'D':56}
print("Series object is created from Dictionary")
sd = pd.Series(dic)
print("Series")
print(sd)
nd = np.arange(1,10)
print("Series Object by ndarray")
sn = pd.Series(nd)
print(sn)
Output:
Series object is created from Dictionary
Series
A 22
B 32
C 45
D 56
dtype: int64
Series Object by ndarray
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
dtype: int64
1|Page
2. Given a series, print all the elements that are more than 50000.
Script:
import pandas as pd
def print_elements_greater_than_50000(series):
for value in series:
if value > 50000:
print(value)
s = pd.Series([10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000])
print_elements_greater_than_50000(s)
Output:
60000
70000
80000
90000
2|Page
3. Create a Data Frame, quarterly sales, where each row contains the item category, item name, and
expenditure. Group the rows by the category and print the total expenditure per category.
Script:
import pandas as pd
sales_data = { "item_category" : ["food", "drink", "food", "sweet", "food", "sweet", "drink", "drink"],
"item_name" : ["maggi", "pepsi", "rajma rice", "gulab jamun", "chapati", "rasgulla", "coca cola", "mirinda"],
"expenditure" : [40, 68, 120, 80, 30, 160, 80, 90]}
sales_quart =pd.DataFrame(sales_data)
print(sales_quart)
gdf=sales_quart.groupby("item_category")
new_df=gdf["expenditure"].sum()
print(new_df)
Output:
3|Page
4. Create a data frame for examination result and display row labels, column labels data types of each
column and the dimensions.
Script:
import pandas as pd
marks ={ "English" : [67,89,69,99], "Maths" : [55,67,49,56], "IP" : [85,77,69,58]}
result = pd.DataFrame(marks, index=["Anu", "Ranjana", "Pawan", "Mahesh"])
print(result)
print("***row label***")
print(result.index)
print("***column label***")
print(result.columns)
Output:
4|Page
5. Filter out rows based on different criteria such as duplicate rows.
Script:
import pandas as pd
sales_data = { "item_category" :["food", "drink", "food", "sweet", "food", "sweet", "drink", "drink"],
"item_name": ["maggi", "pepsi", "rajma rice", "gulab jamun", "maggi", "rasgulla", "pepsi", "mirinda"],
"expenditure": [40, 68, 120, 80, 30, 160, 80, 90]}
df =pd.DataFrame(sales_data)
print(df)
print("Duplicate rows are: " )
print(df [df.duplicated(keep=False)])
print("Duplicate rows on the basis of item name are: " )
print(df [df.duplicated("item_name", keep=False)])
Output:
5|Page
6. Importing and exporting data between pandas and CSV file.
Script:
import pandas as pd
marks ={ "English" : [67,89,69,99], "Maths" : [55,67,49,56], "IP" : [85,77,69,58]}
result = pd.DataFrame(marks, index=["Anu", "Ranjana", "Pawan", "Mahesh"])
print("*******Marksheet******")
print(result)
result.to_csv("result.csv")
Output:
6|Page
7. Locate the 3 largest values in a data frame.
Script:
import pandas as pd
data={'Name':['Aman', 'Rohit', 'Deepika', 'Kamal', 'Deva', 'Ramesh', 'Adnan'], 'Sales':[8500, 4500, 9300, 8600,
9200, 9600, 8400]}
sales=pd.DataFrame(data)
print(sales.nlargest(3,['Sales']))
Output:
7|Page
8. Write a program to generate a series of 10 numbers with a scalar value of 44.
Script:
import pandas as pd
def fl_scv():
print(pd.Series(44,range(1,11)))
fl_scv()
Output:
8|Page
9. Read the 'Student_result.csv' to create a data frame and do the following operation:
a) To display Adm_No, Gender and Percentage from 'student_result.csv' file.
b) To display the first 5 and last 5 records from 'student_result.csv' file.
Script:
import pandas as pd
import csv
df = pd.read_csv("student_result.csv",usecols = ['ADM_NO','GENDER', 'PERCENTAGE'])
print("To display Adm_No, Gender and Percentage from 'student_result.csv'file.")
print(df)
df1 = pd.read_csv("student_result.csv")
print(df1.head())
print(df1.tail())
Output:
9|Page
10. Create the following DataFrame Sales containing year wise sales figures for five salespersons in INR. Use
the years as column labels and salesperson names as row labels.
Name/Sales 2018 2019 2020 2021
Megha 110 205 177 189
Karan 130 165 175 198
Dev 115 206 157 179
Radha 118 198 183 169
a) Create the DataFrame.
b) Display the row labels of Sales.
c) Display the column labels of Sales.
d) Display the data types of each column of Sales.
e) Display the dimensions, shape, size and values of Sales.
Script:
import pandas as pd
d = {2018:[110, 130, 115, 118], 2019:[205, 165, 206, 198], 2020:[117, 175, 157, 183], 2021:[189, 198, 179,
169]}
sales=pd.DataFrame(d,index=['Megha','Karan','Dev','Radha'])
print("Row Lables:\n",sales.index)
print("~~~~~~~~~~~~~~~~~~~~~~~~~~\n")
print("Column Lables:\n",sales.columns)
print("~~~~~~~~~~~~~~~~~~~~~~~~~~\n")
print("\nDisplay column data types")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~")
print(sales.dtypes)
print("\nDisplay the dimensions, shape, size and values of Sales")
print("~~~~~~~~~~~~~~~~~~~~~~~~~~")
print("Dimensions:", sales.ndim)
print("Shape:", sales.shape)
print("Size:", sales.size)
print("Values:", sales.values)
10 | P a g e
Output:
11 | P a g e
11. Consider above dataframe in previous question and write code to do the following:
a) Display the last two rows of Sales.
b) Display the first two columns of Sales.
Script:
import pandas as pd
d = {2018: [110, 130, 115, 118], 2019: [205, 165, 206, 198], 2020: [117, 175, 157, 183], 2021:[189, 198, 179,
169]}
sales=pd.DataFrame(d,index=['Megha', 'Karan', 'Dev', 'Radha'])
print("Display last two rows of DataFrame:")
print("*************************************")
print("Using tail function:")
print(sales.tail(2))
print("*************************************")
print("Using iloc")
print(sales.iloc[-2:])
Output:
12 | P a g e
12. Write a panda program to read marks detail of Manish and calculate sum of all marks.
#data = {'Manish': ['Physics', 'Chemistry', 'English', 'Maths', 'Informatics Practices'], 'marks': [89, 99, 97, 99, 98]}
Script:
import pandas as pd
import numpy as np
data = {'Manish': ['Physics', 'Chemistry', 'English','Maths', 'Informatics Practices'], 'marks': [ 89,99,97,99,98],}
df = pd.DataFrame(data )
print("Sum of Marks:")
print(df['marks'].sum())
Output:
13 | P a g e
13. Write a Pandas program to add, subtract, multiple and divide two Pandas Series.
Script:
import pandas as pd
ds1 = pd.Series([2, 4, 6, 8, 10])
ds2 = pd.Series([1, 3, 5, 7, 9])
ds = ds1 + ds2
print("Add two Series:")
print(ds)
print("Subtract two Series:")
ds = ds1 - ds2
print(ds)
print("Multiply two Series:")
ds = ds1 * ds2
print(ds)
print("Divide Series1 by Series2:")
ds = ds1 / ds2
print(ds)
Output:
14 | P a g e
14. Write a program to generate a series of 5 elements with the elements that are multiple of 7. Start the
series with the value 35. Also, multiply the index with 3.
Script:
import pandas as pd
import numpy as np
def Ser_mul7():
a = 35
n = np.arange(a,a*2,7)
s = pd.Series(index=n*3,data=n)
print(s)
Ser_mul7()
Output:
15 | P a g e
15. Write a program to generate a series and print the top 5 elements using the head function.
Script:
import pandas as pd
ser_length = int(input("Enter the length of the series: "))
data = []
for i in range(ser_length):
val = int(input("Enter a val:"))
data.append(val)
ser = pd.Series(data)
print(ser.head(5))
Output:
16 | P a g e
16. Write a program to generate a series of 10 numbers. Change the value of all the elements to 21 those
values are multiples of 4.
Script:
import pandas as pd
numbers = []
for i in range(1,11):
val = int(input("Enter a number :"))
numbers.append(val)
ser = pd.Series(numbers)
ser[ser % 4 == 0] = 21
print(ser)
Output:
17 | P a g e
17. Given the school result data, analyses the performance of the students on different parameters, e.g
subject-wise or class-wise.
Script:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
marks = { "English" :[67,89,90,55], "Maths":[55,67,45,56], "IP":[66,78,89,90], "Chemistry" :[45,56,67,65],
"Biology": [54,65,76,87]}
df = pd.DataFrame(marks, index=['Siya', 'Arav', 'Ishi', 'Yash'])
print("******************Marksheet****************")
print(df)
df.plot(kind='bar')
plt.xlabel(" ")
plt.ylabel(" ")
plt.show()
Output:
18 | P a g e
18. Take data of your interest from an open source (e.g. data.gov.in), aggregate and summarise it. Then plot it
using different plotting functions of the Matplotlib library.
Script:
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("C:\Book1.csv")
print(df)
df.plot(kind='bar')
plt.title('Census')
plt.xlabel("")
plt.ylabel("")
plt.show()
Output:
19 | P a g e
19. Draw the histogram based on the Production of Wheat in different Years:
Year: 2000, 2002, 2004, 2006, 2008, 2010, 2012, 2014, 2016, 2018
Production: 4, 6, 7, 15, 24, 2, 19, 5, 16, 4
Script:
import pandas as pd
import matplotlib.pyplot as plt
data={'Year':[2000,2002,2004,2006,2008,2010,2012,2014,2016,2018], 'Production':[4,6,7,15,24,2,19,5,16,4]}
d=pd.DataFrame(data)
print(d)
x=d.hist(column='Production', bins=5, grid=True)
plt.show()
Output:
20 | P a g e
20. The table shows passenger car fuel rates in miles per gallon for several years. Make a line graph of the
data. During which 2-year period did the fuel rate decrease?
Year: 2000 2002 2004 2006 Rate: 21.0 20.7 21.2 21.6
Scripts:
import matplotlib.pyplot as plt
Yr=[2000,2002,2004,2006]
rate=[21.0,20.7,21.2,21.6]
plt.plot(Yr,rate)
plt.show()
Output:
21 | P a g e
21. The number of students in 7 different classes is given below. Represent this data on the bar graph.
Class 6 7 8 9 10 11 12
No. of Students 100 120 103 112 119 125 95
Scripts:
import matplotlib.pyplot as p
x=[6,7,8,9,10,11,12]
y=[100,120,103,112,119,125,95]
p.title('class strength')
p.xlabel('class')
p.ylabel('no of students')
p.bar(x, y)
p.show()
Output:
22 | P a g e
22. Create a student table with the student_id, name, and marks as attributes where the student_id is the
primary key.
Query:
Output:
i. Insert the details of a new student in the above table.
Query:
Output:
23 | P a g e
ii. Delete the details of a student in the above table.
Query:
Output:
iii. Use the select command to get the details of the students with marks more than 420.
Query & Output:
iv. Find the min, max, sum, and average of the marks in a student marks table.
Query & Output:
24 | P a g e
23. Find the total number of customers from each country in the table (customer ID, customer Name, country)
using group by.
Query & Output:
24. Write a SQL query to order the (student ID, marks) table in descending order of the marks
Query & Output:
25 | P a g e
25. Write MySQL Command based on the table Product.
PCode PName Price Qty
P01 Adapter 350 20
P02 Cable 180 25
P03 Speaker 450 30
P04 Router 550 22
P05 Processor 10000 10
i. To display the name of the entire product with price more than 300.
Query & Output:
ii. To display the name of all the products by the quantity more than 25.
Query & Output:
iii. To add a new row for product with the details : “P06”, “Monitor”, 3300, 15
Query & Output:
26 | P a g e
iv. Display the product with highest price.
Query & Output:
v. What are the total number of records in the table?
Query & Output:
27 | P a g e