0% found this document useful (0 votes)
26 views32 pages

Practical File Sai Lalit

Uploaded by

mzubairbaig07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views32 pages

Practical File Sai Lalit

Uploaded by

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

New Middle East International School, Riyadh

(Affiliated to CBSE New Delhi)

Informatics Practices Record

Submitted By
Name: Kakumani Sai Lalit Chandra
Reg. No:
CERTIFICATE

NEW MIDDLE EAST INTERNATIONAL SCHOOL


INFORMATICS PRACTICES PRACTICAL RECORD

This is to certify that it is a bona fide record of practical work


done in Informatics Practices by Kakumani Sai Lalit Chandra of
Class 12-E in accordance with the CBSE syllabus of AISSCE at
New Middle East International School, Riyadh during the
academic year 2024-25.

External Examiner Internal Examiner

Principal
Contents

Sl. No Program Name Page No.


Data Handling using Pandas
1 Creating Series in Different Methods 1
2 Creating Series with a Dictionary 2
3 Modifying a Series 3
4 Comparing a Series 4
5 Vector Operations on Series 5
6 Temperatures with Series 6
7 Quarterly Sales with DataFrames 7
8 Student Data with DataFrames 8
9 BMI Calculator 9
10 Displaying Data from DataFrame 10
11 Staff Average Salary 11
12 Person Wise Sales Figures 12
13 Modification of DataFrame 13
14 Storing to a CSV 14
15 Reading From a CSV 15
Data Visualization using Matplotlib
16 Analysis of Olympic Games 16
17 Analysis of Bike Sales 17
18 Analysis of Student Performance 19
19 Analysis of Seat Bookings 20
20 Average Marks Per Subject 21
Data Management using MySQL
21 SQL 23
Page 1

Program 1
Question: Write a program to create a Series object using (a) Scalar
Value (b) List (c) ndarray
Program:
scalar_value = eval(input("Please input a scalar value: "))
Sn = pd.Series(scalar_value)
print(Sn)
list1 = eval(input("Please input a list: "))
Sn = pd.Series(list1)
print(Sn)
list1 = eval(input("Please input a list which is to be converted into an
array: "))
ar1 = np.array(list1)
Sn = pd.Series(ar1)
print(Sn)
Output:
Page 2

Program 2
Question: Write a program to create a Series object using a dictionary
that stores the number of students in each section of class 12 in your
school[Sections: A,B,C,D,E,F,G,H Strength: 24,23,20,22,22,24,10,15]
Program:
dict1 = {'A': 24, 'B': 23, 'C': 20, 'D': 22, 'E': 22, 'F': 24, 'G': 10, 'H': 15}
Sn = pd.Series(dict1)
print(Sn)
Output:
Page 3

Program 3
Question: Write a program to create a Series object that stores the
contribution of each section, as shown below:

Modify the amount of Section A as 3400 and for section C and D as


5000. Print the modified Series.
Program:
dict1 = {'A': 4300, 'B': 6500, 'C': 3900, 'D': 6100}
Sn = pd.Series(dict1)
print(Sn)
Sn['A'] = 3400
Sn['C'] = 5000
Sn['D'] = 5000
print(Sn)
Output:
Page 4

Program 4
Question: Write a program to compare the elements of two Series

Program:
dict1 = {0:2, 1:4, 2:6, 3:8, 4:10}
dict2 = {0:1, 1:3, 2:5, 3:7, 4:9}
Sn1 = pd.Series(dict1)
Sn2 = pd.Series(dict2)
print('Sn1>Sn2')
print(Sn1>Sn2)
print('Sn1<Sn2')
print(Sn1<Sn2)
print('Sn1=Sn2')
print(Sn1==Sn2)
Output:
Page 5

Program 5
Question: Write a program to create a Series that contains the marks
of five students in one subject. Print all marks that are greater than
75.
Program:
dict1 = {'Rajesh':70, 'Rick':75, 'Rohit':80, 'Ravi':85, 'Rahul':90}
Sn1 = pd.Series(dict1)
print(Sn1[Sn1>75])
Output:
Page 6

Program 6
Question: Create a Series temp that stores temperature of seven days
in it. Its index should be Sunday, Monday, … Write a program to
a. Display temperature of first 3 days.
b. Display temperature of last 3 days.
c. Display all temperature in reverse order like Saturday, Friday, ...
d. Display square of all temperature
Program:
listtemp = [30, 32, 35, 33, 39, 29, 35]
Sn1 = pd.Series(listtemp, index=
['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'])
print(Sn1.head(3))
print(Sn1.tail(3))
print(Sn1[::-1])
print(Sn1**2)
Output:
Page 7

Program 7
Question: Write a program to create a dataframe quarterly sales
where each row contains the quarterly sales of TV, Fridge and AC.
Show the dataframe after deleting the details of AC.

Program:
dict1 = {'TV': [20000,10000,15000,14500],'Fridge':
[15000,22000,10000,11000],'AC': [25000,12000,9000,19000]}
df1 = pd.DataFrame(dict1,index=['Qtr1','Qtr2','Qtr3','Qtr4'])
del df1['AC']
print(df1)
Output:
Page 8

Program 8
Question: Write a program to create a dataframe to store rollnumber,
name and marks of five students. Print the dataframe, along with the
number of rows, columns and total elements in the dataframe and
also its transpose.

Program:
dict1 = {'Rollnumber': [101,102,103,104,105],'Name':
['Karan','Taran','Piyush','Bhupinder','Simran'],'Marks': [82,86,79,86,94]}
df = pd.DataFrame(dict1)
print(len(df.index))
print(len(df.columns))
print(df.size)
print(df.T)
Output:
Page 9

Program 9
Question: Write a program to create a dataframe which contains
Rollnumber, Name, Height, Weight of 5 students. Add a column
BMI(Body Mass Index) using appropriate formula.

Program:
dict1 ={'Rollnumber':[1,2,3,4,5],'Name':['A','B','C','D','E'],'Height':
[1.65,1.68,1.80,1.74,1.72],'Weight':[72,71,73,71,72]}
df = pd.DataFrame(dict1)
df['BMI'] = df['Weight']/(df['Height']**2)
print(df)
Output:
Page 10

Program 10
Question: Write a program to create a dataframe AID using the data
given below and do the following.
a. Display the books and shoes only
b. Display toys only
c. Display quantity in MP and CG for toys and books. d. Display
quantity of books in AP

Program:
dict1 = {'Toys':
[7000,3400,7800,4100],'Books':
[4300,3200,5600,2000],'Shoes':
[6000,1200,3280,3000]}
AID = pd.DataFrame(dict1,
index=['MP','UP','AP','CG'])
print(AID)
print(AID.loc[:,'Books':'Shoes'])
print(AID.Toys)
print(AID.loc['MP':'CG':3,'Toys':'B
ooks'])
Output:
Page 11

Program 11
Question: Consider two series object Staff and salaries that stores the
number of people in various branches and salaries distributed in
these branches respectively. Write a program to create another
Series object that stores average salary per branch and then create a
dataframe object from these Series object. After creating dataframe
rename all row labels with Branch name.
Program:
staff = pd.Series([15, 50, 20])
salary = pd.Series([1500000, 4000000, 1300000])
avg = pd.Series(salary/staff)
branch = ['IT','Marketing','HR']
df = pd.DataFrame({'Branch':branch,'Staff':staff,'Total
Salary':salary,'Avg_Salary':avg})
print(df)
df.set_index('Branch',inplace=True)
print(df)
Output:
Page 12

Program 12
Question: Write a program to create the dataframe sales containing year wise
sale figure for five sales persons in INR. Use the year as column labels and the
sales person names as row labels.

Write script to do the following:


a. Display the row labels of sales
b. Display the column labels of sales
c. Display the last two rows of sales
d. Display the first two rows of sales
Program:
dict1 = {2014:[1000,1500,2000,3000,4000],2015:[2000,1800,2200,3000,4500],2016:
[4000,5000,7000,1000,1250],2017:[2800,6000,7000,8000,9000]}
df = pd.DataFrame(dict1, index= ['Madhu','Kusum','Kinshuk','Ankit','Shruti'])
print(df.index)
print(df.columns)
print(df.tail(2))
print(df.head(2))
Output:
Page 13

Program 13
Question: Write a program to create a dataframe Accessories using data as
given below and write program to do the following:

a. Increase price of all accessories by 10%


b. Rename all indexes to [C001,C002,C003,C004,C005]
c. Delete the data of C003 from the dataframe
d. Delete quantity from the dataframe

Program:
dict1 = {'Cname': ['Motherboard','Hard
Disk','Keyboard','LCD'],'Quantity':
[15,24,10,30],'Price':
[1200,5000,500,450]}
df = pd.DataFrame(dict1,
index=['C1','C2','C3','C4'])
print(df)
df['Price'] = df['Price']*(110/100)
print(df)
df.rename(index={'C1':'C001','C2':'C002'
,'C3':'C003','C4':'C004'}, inplace=True)
print(df)
df.drop('C003',axis=0,inplace=True)
print(df)
del df['Quantity']
print(df)
Page 14

Program 14
Question: Write a program to create a dataframe using the following
data and store it into a csv file student.csv without row labels and
column labels.

Program:
dict1 = {'Rollnumber': [101,102,103,104,105],'Name':
['Karan','Taran','Piyush','Bhupinder','Simran'],'Marks': [82,86,79,86,94]}
df = pd.DataFrame(dict1)
df.to_csv('D:/file.csv',index=False,header=False)
Output:
Page 15

Program 15
Question: Write a program to read the contents of the csv file
student.csv and display it. Update the row labels and column labels
to be same as that of previous question.

Program:
df = pd.read_csv('D:/student.csv',
names=['Rollnumber','Name','Marks'])
print(df)
Output:
Page 16

Program 16
Question: Collect and store total medals won by 10 countries in
Olympic games and represent it in form of bar chart with title to
compare and analyse data.

Program:
medals = [10,8,15,26,13,2,3,7,6,4]
countries =
['UK','USA','GERMANY','AUSTRALIA','ITALY','SPAIN','FRANCE','SWITZERL
AND','TURKEY','INDIA']
plt.bar(countries, medals, color = 'orange')
plt.title('Medals won in Olympics')
plt.show()
Output:
Page 17

Program 17
Question: Techtipow Automobiles is authorized dealer of different
bike companies. They record the entire sale of bike month wise as
given below.

To get a proper analysis of sale performance create multiple line


chart on a common plot where all bike sale are plotted. Display
appropriate x and y axis labels, legend and chart title.
Program:
month = ['Jan','Feb','Mar','Apr','May','Jun']
honda = [23,45,109,87,95,100]
suzuki = [45,57,75,60,50,30]
TVS_bikes = [97,80,84,68,80,108]
plt.plot(month, honda, color='pink', ls = '-.')
plt.plot(month, suzuki, color='red', ls = 'dotted')
plt.plot(month, TVS_bikes, color='blue', ls = '--')
plt.legend(['Honda', 'Suzuki', 'TVS'])
plt.xlabel('Months')
plt.ylabel('No. of Bikes')
plt.show()
Page 18

Output:
Page 19

Program 18
Question: Given the school result data, analyse the student
performance on different parameters, e.g., subject wise or class wise.
Create a dataframe for the above , plot appropriate chart with title
and legend.

Program:
dict1 = {'Eng':[78,89,67,88],'Math':[89,91,95,78],'Phy':
[69,70,96,65],'Chem':[92,85,94,87],'IT':[90,98,90,80]}
df = pd.DataFrame(dict1, index=[9,10,11,12])
df.plot(kind='bar')
plt.show()
Output:
Page 20

Program 19
Question: The following seat bookings are the daily records of a
month from a cinema hall.
124,124,135,156,128,189,200,176,156,145,138,200,178,189,156,124,1
42,156,176,180,199,154, 167,198,143,150,144,152,150,143
Construct a histogram for the above data with 10 bins.
Program:
seats =
[124,124,135,156,128,189,200,176,156,145,138,200,178,189,156,124,
142,156,176,180,199,154,167,198,143,150,144,152,150,143]
nbins = 10
plt.hist(seats,bins=nbins, facecolor = 'pink', edgecolor = 'red', linewidth
= 3)
plt.show()
Output:
Page 21

Program 20
Question: Write a program to create a dataframe for subject wise
average, save it to a CSV file and then draw a bar chart with a width
of each bar as 0.25, specifying different colors for each bars.
Additionally, provide a proper title and axes labels for the bar chart.

Program:
sub_list = ['Eng','Phy','Chem','Maths','IP']
marks_list = [72,85,90,89,100]
dict1 = {'Subject': sub_list,'Avg Marks': marks_list}
df = pd.DataFrame(dict1, index=['Sub1','Sub2','Sub3','Sub4','Sub5'])
print(df)
df.to_csv(r'D:\subject_wise_average_marks.csv')
plt.bar(sub_list,marks_list,width=0.25,color = ['red','blue','green','yellow','pink'])
plt.xlabel('Subjects')
plt.ylabel('Marks')
plt.title('Subject Wise Average Marks')
plt.show()
Page 22

Output:
Page 23

Program 21
Question: To write Queries for the following questions based on the
given table:

A. Create a database EMPS and open it.


CREATE DATABASE EMPS;
USE EMPS;

B. Create the above table Employee with Empid as primary key.


CREATE TABLE Employee
(Empid integer NOT NULL PRIMARY KEY,
Name varchar(20),
Age char(2),
Gender char(1),
Dept varchar(10),
DOJ date,
Salary integer,
City varchar(10));
Page 24

C. Write queries to insert all the rows of the above table.


INSERT INTO Employee (Empid, Name, Age, Gender, Dept, DOJ,
Salary, City)
VALUES (1,'Praveen',25,'M','Sales','1989-06-08',20000,'Chennai'),
(2,'Arun',29,'M','Marketing',' 1989-09-26',22000,'Chennai'),
(3,'Usha',27,'F',' Finance',' 1994-08-09',25000,'Bangalore'),
(4,'Bala',31,'M','Sales',' 1990-03-23',27000,NULL),
(5,'Rani',29,'F', 'Marketing',' 1990-04-23',27000,'Mumbai'),
(6,'Nisha',26,'F',NULL,' 1991-02-24',18000,'Bangalore'),
(7,'Manoj',32,'M','Finance',' 1982-05-06',30000,'Goa');

D. Display all the details of the above table.


Select*from Employee;
Page 25

E. Display the details of employees whose salary is above 15000


and gender is not male.
SELECT*FROM Employee
WHERE Salary > 15000 AND Gender = 'F ';

F. Increase the salary of an employee who is in Chennai and is a


male by 10%.
UPDATE Employee
SET Salary = Salary*(110/100)
WHERE City = 'Chennai' AND Gender = 'M';

G. Delete details of the employee whose id is 6.


DELETE FROM Employee
WHERE Empid = 6;
Page 26

H. Display the sum, maximum and minimum of salary of all


employees.
SELECT SUM(Salary) FROM Employee;

SELECT MAX(Salary) FROM Employee;

SELECT MIN(Salary) FROM Employee;

I. Display the number of employees who earns more than 20000.


SELECT COUNT(*) FROM Employee
WHERE Salary > 20000;
Page 27

J. Display the names in ascending order of names.


SELECT Name FROM Employee
ORDER BY Name;

K. Display the sum of salary department wise.


SELECT SUM(Salary) FROM Employee
GROUP BY Dept;

L. Display the department names where number of employees are


greater than or equal to 2.
SELECT DISTINCT Dept
FROM Employee
GROUP BY Dept
HAVING COUNT(Dept) >= 2;
Page 28

M. Display the names in upper case from the above table.


SELECT UPPER(Name) FROM Employee;

N. Display the names and the length of each name from the above
table.
SELECT Name, LENGTH(NAME) FROM Employee;
Page 29

O. Display the names of employees whose year of joining is 1990.


SELECT Name FROM Employee
WHERE YEAR(DOJ) = 1990;

You might also like