0% found this document useful (0 votes)
25 views38 pages

Practical File Sample

Uploaded by

abdulruh677
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)
25 views38 pages

Practical File Sample

Uploaded by

abdulruh677
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/ 38

New Middle East International School, Riyadh

(Affiliated to CBSE New Delhi)

Informatics Practices Record

Submitted By
Name : Abdul Rahman Kaleem
Reg. No: 9075
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 Abdul Rahman Kaleem of Class
12 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 with different methods 1
2
3
4
5
6
7
8
9
10
11
12
Program 1
Qn.
Write a program to create a Series object using (a) Scalar Value (b) List (c) ndarray

Program:
val = int(input("enter scalar value: "))

S = pd.Series(val)

print(S)

L = eval(input("enter a list: "))

S = pd.Series(L)

print(S)

L = eval(input("input a list which will be converted to ndarray"))

array = np.array(L)

S = pd.Series(array)

print(S)

Output:
Program 2
Qn.
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:
d = {'A':24,'B':23,'C':20, 'D': 22, 'E': 22,'F': 24,'G':10, 'H': 15}

S = pd.Series(d)

print(S)

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

Program:
d = {'A': 4300, 'B': 6500, 'C': 3900, 'D': 6100}

S = pd.Series(d)

print(S)

S['A'] = 3400

S['C'] = 5000

S['D'] = 5000

print(S)

Output:
Program 4
Qn.
Write a program to compare the elements of two Series

Program:
d1 = {0:2,1:4,2:6,3:8,4:10}

d2 = {0:1,1:3,2:5,3:7,4:9}

S1 = pd.Series(d1)

S2 = pd.Series(d2)

print(S1<S2)

print(S1>S2)

print(S1==S2)

Output:
Program 5
Qn.
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:
d1 = {'abdul':67,'singh':68,'rahul':78,'monica':77,'ayaan':78}

S1 = pd.Series(d1)

print(S1[S1>75])

Output:
Program 6
Qn.
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:
temp = [12,12,13,14,15,13,12]

s=pd.Series(temp,index=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'])

head = s.head(3)

tail = s.tail(3)

rev = s[::-1]

sq = s**2

print(head)

print(tail)

print(rev)

print(sq)

Output:
Program 7
Qn.
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:
d1={'TV':[20000,10000,15000,14500],'Fridge':[15000,22000,10000,11000],'AC':
[25000,12000,9000,19000]}

df1 = pd.DataFrame(d1, index=['Qtr1','Qtr2','Qtr3','Qtr4'])

print(df1)

del df1['AC']

print(df1)

Output:
Program 8
Qn.
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:
d1={'Rollnumber':[101,102,103,104,105],'Name':
['Karan','Taran','Piyush','Bhupinder','Simran'],'Marks': [82,86,79,86,94]}

df = pd.DataFrame(d1)

print(len(df.index))

print(len(df.columns))

print(df.size)

print(df.T)

Output:
Program 9
Qn.
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:
d1={'Rollnumber':[1,2,3,4,5],'Name':['Karan','Taran','Piyush','Bhupinder','Simran'],'Height':
[1.5,1.45,1.23,1.12,1.23],'Weight':[70,71,75,65,82]}

df = pd.DataFrame(d1)

df['BMI'] = df['Weight']/(df['Height']**2)

print(df)

Output:

Program 10
Qn.
10. 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:
d1 = {'Toys':[7000,3400,7800,4100],'Books':[4300,3200,5600,2000],'Shoes':[6000,1200,3280,3000]}

df = pd.DataFrame(d1, index=['MP','UP','AP','CG'])

print(df)

print(df.loc[:,'Books':'Shoes'])

print(df.Toys)

print(df.loc['MP':'CG':3,'Toys':'Books'])

Output:

Program 11
Qn.
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:

Program 12
Qn.
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.
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:
d1 = {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(d1, index= ['Madhu','Kusum','Kinshuk','Ankit','Shruti'])

print(df.index)

print(df.columns)

print(df.tail(2))

print(df.head(2))

Output:

Program 13
Qn.
Wrie a program to create a dataframe Accessories using data as given below and write program to do
the following
a. Increase price of all accesseroies 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:

d1={'Cname':['Motherboard','HardDisk','Keyboard','LCD'],'Quantity':[15,24,10,30],'Price':
[1200,5000,500,450]}

df = pd.DataFrame(d1, 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)

Output:

Program 14
Qn.
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:
d1={'Rollnumber':[101,102,103,104,105],'Name':
['Karan','Taran','Piyush','Bhupinder','Simran'],'Marks': [82,86,79,86,94]}

df = pd.DataFrame(d1)

df.to_csv('C:/yourfilehere.csv',index=False,header=False)

Output:

Program 15
Qn.
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:

Program 16
Qn.
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 analyze data.

Program:
medals = [10,8,15,26,13,2,3,7,6,4]

countries=['UK','USA','GERMANY','AUSTRALIA','ITALY','SPAIN','FRANCE','SWITZERLAND','TURKEY','IND
IA']

plt.bar(countries, medals, color = 'orange')

plt.title('Medals won in Olympics')

plt.show()

Output:

Program 17
Qn.
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()

Output:

Program 18
Qn.
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:

Program 19
Qn.
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,142,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,1
67,198,143,150,144,152,150,143]

nbins = 10

plt.hist(seats,bins=nbins, facecolor = 'pink', edgecolor = 'red', linewidth = 3)

plt.show()

Output:

Program 20
Qn.
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()

Output:

Program 21a
Qn.
Create a database EMPS and open it

Program:
CREATE DATABASE EMPS;

USE EMPS;

Output:

Program 21b
Qn.
Create the above table Employee with Empid as primary key.
Program:
CREATE TABLE Employee (

Empid INT PRIMARY KEY,

Name VARCHAR(50),

Age INT,

Gender CHAR(1),

Dept VARCHAR(20),

DOJ DATE,

Salary INT,

City VARCHAR(50)

);

Output:

Program 21c
Qn.
Write queries to insert all the rows of the above table.
Program:
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');

Output:

Program 21d
Qn.
Display all the details of the above table
Program:
SELECT * FROM Employee;

Output:

Program 21e
Qn.
Display the details of employees whose salary is above 15000 and gender is not male.
Program:
SELECT * FROM Employee WHERE Salary > 15000 AND Gender != 'M';

Output:

Program 21f
Qn.
Increase the salary of an employee who is in Chennai and is a male by 10%
Program:
UPDATE Employee SET Salary = Salary * 1.1 WHERE City = 'Chennai' AND Gender = 'M';

Output:

Program 21g
Qn.
Delete details of the employee whose id is 6

Program:
DELETE FROM Employee WHERE Empid = 6;

Output:

Program 21h
Qn.
Display the sum, maximum and minimum of salary of all employees.

Program:
SELECT SUM(Salary), MAX(Salary), MIN(Salary) FROM Employee;
Output:

Program 21i
Qn.
Display the number of employees who earns more than 20000.

Program:
SELECT COUNT(*) FROM Employee WHERE Salary > 20000;
Output:

Program 21j
Qn.
Display the names in ascending order of names

Program:

SELECT Name FROM Employee ORDER BY Name ASC;


Output:

Program 21k
Qn.
Display the sum of salary department wise

Program:
SELECT Dept, SUM(Salary) FROM Employee GROUP BY Dept;
Output:

Program 21 L
Qn.
Display the department names where number of employees are greater than or equal to
2.

Program:
SELECT Dept FROM Employee GROUP BY Dept HAVING COUNT(*) >= 2;

Output:

Program 21m
Qn.
Display the names in upper case from the above table.

Program:
SELECT UPPER(Name) FROM Employee;
Output:

Program 21n
Qn.
Display the names and the length of each name from the above table.

Program:
SELECT Name, LENGTH(Name) FROM Employee;
Output:

Program 21o
Qn.
Display the names of employees whose year of joining is 1990.

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

You might also like