Final Print
Final Print
PRACTICAL RECORD
NAME :
CLASS :
REGISTER NO : YEAR :
External examiner:
INFORMATICS PRACTICES (065)
PRACTICAL PROGRAMS
CLASS 12 – 2024 -25
TABLE OF CONTENTS
SNO NAME OF EXERCISES PAGE DATE REMARKS
AIM:
To write a Python program to create a Series to store 5 students Percentage Using dictionary and
print
all the elements that are above 75 percentage.
SOURCE CODE:
import pandas as pd
D={"Arun":65, "Bala": 91, "Charan" : 74, "Dinesh" : 80, "Usha": 85}
S=pd. Series (D)
print (S[S>75])
RESULT:
Thus, the above Python program has been executed successfully, and the output has been
verified.
SAMPLE OUTPUT:
***************************************************************************
1
EX.NO: 2
DATE: 13/6/24
PYTHON PROGRAM TO CREATE A SERIES USING SCALAR VALUE
AIM:
To write a Python program to create a Series object that stores the Initial budget allocated
(50000/- each) for the four quarters of the year: Qtr1, Qtr2, Qtr3 and Qtr4.
SOURCE CODE:
import pandas as pd
Budget-pd.Series (50000, index=['Qtrl', 'Qtr2', 'Qtr3', 'Qtr4'])
print (Budget)
RESULT:
Thus, the above Python program has been executed successfully, and the output has been
verified.
SAMPLE OUPUT:
***************************************************************************
2
EX.NO: 3
DATE: 14/6/24
PYTHON PROGRAM TO CREATE A SERIES USING NUMPY ARRAY
AIM:
To write a Python program to create a Series object that stores the Employee names
as index and their Salary as values
SOURCE CODE:
import pandas as pd
import numpy as np
Section=['A', 'B', 'C']
Contribution=np.array([6700, 5500, np. NaN])
S=pd. Series (data=Contribution, index=Section)
print (S)
RESULT:
Thus, the above Python program has been executed successfully, and the output has been
verified.
SAMPLE OUTPUT:
***************************************************************************
3
EX.NO: 4
DATE: 14/6/24
SOURCE CODE:
import pandas as pd
D= {'John': 50000, 'Bala': 60000, 'Anu': 55000, 'Birundha': 52000}
S= pd.Series(D)
print("Employees Salary Before updating")
print(S)
print("\n")
Name= input("Enter the name of the employee: ")
if Name in S:
new_salary = float(input("Enter the new salary: "))
S[Name] = new_salary
print("\nSalary updated successfully!")
print("\nEmployees Salary After updating")
print(S)
else:
print("\nEmployee not found in the records.")
print("\nThank You!!!")
RESULT:
Thus, the above Python program has been executed successfully, and the output has been
verified.
4
SAMPLE OUPUT:
*****************************************************************************
5
EX.NO: 5
DATE: 20/6/24
PYTHON PROGRAM FOR PERFORMING MATHEMATICAL
OPERATIONS ON TWO SERIES OBJECTS
AIM:
To create a program in python to perform following mathematical Operations on Two
Series objects: (i) Addition (ii) Subtraction (iii) Multiplication (iv) Division.
SOURCE CODE:
import pandas as pd
S1=pd.Series ([10,20,30], index=['a', 'b', 'c']) $2=pd. Series ([2,5], index= ['a', 'b'])
print("The Addition of two series object is: ")
print (S1+S2)
print("The Subtraction of two series object is:")
print (S1-S2)
print("The Multiplication of two series object is: ")
print (S1*S2)
print ("The Division of two series object is: ")
print (S1/S2)
RESULT:
Thus, the above Python program has been executed successfully, and the output has been
verified.
SAMPLE OUTPUT
***************************************************************************
6
EX.NO: 6
DATE: 20/6/24
SOURCE CODE:
import pandas as pd
population=pd.Series([5200,2100,4523,3422], index=['East','West', 'South', 'North'])
avgincome=pd.Series([117832,587324,171802,235038], index=['East','West', 'South', 'North'])
perCapitaIncome=avgincome/population
print("Percapita Income of Four Zones are:")
print("\n")
print(perCapitaIncome)
RESULT:
Thus, the above Python program has been executed successfully, and the output has been
verified.
SAMPLE OUTPUT:
***************************************************************************
7
EX.NO: 7
DATE: 21/6/24
AIM:
To write a Python program to create a Series using list and display the following
attributes of the Series: (i) index (ii) dtype (iii) size (iv) shape (v) hasnans
SOURCE CODE:
RESULT:
Thus, the above Python program has been executed successfully, and the output has been
verified.
SAMPLE OUTPUT:
***************************************************************************
8
EX.NO: 8
DATE: 21/6/24
PYTHON PROGRAM USING head() AND tail() IN SERIES
AIM:
To write a Python program to create a Series using list of Marks of 10 students and
display first 5 Students’ marks and Last 2 Students’ marks from Series object.
SOURCE CODE:
import pandas as pd
Marks [67,89,90,86,100,45,83,43,66,55]
S=pd. Series (Marks, index=['Stul', 'Stu2', 'Stu3', 'Stu4', 'Stu5', 'Stu6', 'Stu7', 'Stu8', 'Stu9',
'Stu10'])
print ("The First five student marks are: ")
print (S.head())
print ("\n")
print ("The Last two students marks are: ")
print (S.tail (2))
RESULT:
Thus, the above Python program has been executed successfully, and the output has been
verified.
SAMPLE OUTPUT:
*****************************************************************************
9
EX.NO: 9
DATE: 26/6/24
AIM:
To write a Python program to create a pandas Data Frame for the following table Using
Nested list:
SOURCE CODE:
import pandas as pd
L=[['Arun', 21], ['Bala',23], ['Charan',22]]
D=pd.DataFrame (L, index=['Stul', 'Stu2', 'Stu3'], columns=['Name', 'Age'])
print (D)
RESULT:
Thus, the above Python program has been executed successfully, and the output has been
verified.
SAMPLE OUTPUT:
****************************************************************************
10
EX.NO: 10
DATE: 26/6/24
PYTHON PROGRAM FOR ACCESSING VALUES OF ROWS AND
COLUMNS OF A DATAFRAME
AIM:
To write a Python program to create a panda’s DataFrame called DF for the following
table Using Dictionary of List and perform the following operations:
SOURCE CODE:
import pandas as pd
D={'Toys' : [7916,8508,7226,7617],
'Books': [61896, 8208,6149,6157], 'Uniform': [610,508,611,457],'Shoes': 8810,6798,9611,6457]}
DF=pd.DataFrame (D, index=['AP', 'OD', 'M. P', 'U.P'])
print ("The details of Toys are: ")
print (DF.loc[:, 'Toys'])
print("\n")
print("The details of AP and OD are: ")
print (DF.loc['AP': 'OD', ])
print ("\n")
print("The details of MP and U.P are:")
print (DF.loc['M.P': 'U.P', 'Books': 'Uniform']) print ("\n")
print('Consecutive 3 Rows and 3 Columns are:')
print (DF.iloc[0:3,0:3])
11
RESULT:
Thus, the above Python program has been executed successfully, and the output has been
verified.
SAMPLE OUTPUT:
*************************************************************************
12
EX.NO: 11
DATE: 27/6/24
To write a Python program to create a pandas DataFrame called DF for the following
table Using Dictionary of List and perform the following operations:
(i) Insert a new column “Bags” with values as [5891, 8628, 9785, 4475].
(ii) Delete the row details of M.P from DataFrame DF.
SOURCE CODE:
import pandas as pd
D={'Toys': [7916,8508,7226,7617],
'Books': [61896, 8208,6149,6157], 'Uniform': [610,508,611,457],
'Shoes': [8810,6798,9611,6457]}
DF=pd.DataFrame (D, index=['AP', 'OD', 'M.P', 'U.P'])
DF ['Bags']=[5891, 8628, 9785, 4475] # Adding a new column Bags
print ("After Adding a new column: ")
print (DF)
print("\n")
S=DF.drop('M.P') # Deleting M.P details.
print ("After Deleting M.P details:")
print(S)
RESULT:
Thus, the above Python program has been executed successfully, and the output has been
verified.
13
SAMPLE OUTPUT:
*****************************************************************************
14
EX.NO: 12
DATE: 27/6/24
PYTHON PROGRAM TO PERFORM OPERATIONS ON A DATAFRAME
(RENAME, COUNT, UPDATE, REPLACE)
AIM:
To write a Python program to create a pandas DataFrame to analyze number of
Government and Private medical college and their Total seats,Fees, statewise details
using the dataset available at www.data.gov.in. Also, perform the following operations.
(i) To Change the name of the state AP to Andhra.
(ii) To Count and Display Non-NaN values of each column.
(iii) To Count and Display Non-NaN values of each row.
(iv) To Increase the fees of all colleges by 5%
(v) To Replace all NaN values with 0.
SOURCE CODE:
RESULT:
Thus, the above Python program has been executed successfully, and the output has been
verified.
15
SAMPLE OUTPUT:
***************************************************************************
16
EX.NO: 13
DATE: 5/7/24
SOURCE CODE:
import pandas as pd
D={'Stu_Name': ['Anu', 'Arun', 'Bala', 'Charan', 'Mano'], 'Degree': ['MBA', 'MCA', 'M.E', 'M.Sc',
'MCA'],'Percentage': [90,85,91,76,84]}
RESULT:
Thus, the above Python program has been executed successfully, and the output has been
verified.
SAMPLE OUTPUT:
*************************************************************************
17
EX.NO: 14
DATE: 5/7/24
SOURCE CODE:
import pandas as pd
D={'Stu_Name': ['Anu', 'Bala', 'Charan', 'Mano'], 'Degree':['MBA','MCA', 'M.E','M.Sc'],
'Percent':[90,85,91,76]}
RESULT:
Thus, the above Python program is executed successfully and the output is verified.
SAMPLE OUTPUT:
*****************************************************************************
18
EX.NO: 15
DATE: 12/7/24
SOURCE CODE:
import pandas as pd
D={"Stu_Name": ["Anu", "Arun", "Bala", "Charan", "Mano"], "Degree": ["MBA", "MCA",
"M.E", "M.Sc", "MCA"], "Percentage" : [90,85,91,76,84]}
DF=pd.DataFrame (D, index=["S1", "$2", "S3", "S4", "s5"])
for (row, values) in DF.iterrows():
print (row)
print (values)
print () #To print an empty line after each row.
for (col, values) in DF.iteritems () :
print (col)
print (values)
print ()
RESULT:
Thus, the above Python program has been executed successfully, and the output has been
verified.
SAMPLE OUTPUT:
19
*****************************************************************************
20
EX.NO: 16
DATE: 18/7/24
PYTHON PROGRAM TO PERFORM WRITING AND READING OPERATIONS
IN A CSV FILE
AIM:
To Write a Python program to store the details of Employess’ such as Empno, Name,
Salary into a Employee.csv file. Also, write a code to read employee details from csv
file.
SOURCE CODE:
import pandas as pd
Emp={"Name": [ "Anu", "Ram", "Raj", "Mano", "Rajan"],"Age" : [25,27,35,27,32],
"State":["TN", "AP", "TN", "KA", "AP"],"Salary" : [26000,35000,45000,25000,37000]}
DF-pd.DataFrame (Emp, index= ["E1", "E2", "E3", "E4", "E5"])
DF.to_csv("E:\\Data\\Emp.csv")
Data=pd.read_csv("E:\\Data\\Emp.csv")
print (Data)
RESULT:
Thus, the above Python program has been executed successfully, and the output has been
verified.
SAMPLE OUTPUT:
**************************************************************************
21
EX.NO: 17
DATE: 24/7/24
PYTHON PROGRAM FOR PLOTTING A LINE CHART
AIM:
To write a Python program to plot a Line chart to depict the changing weekly Onion
and Brinjal prices for four weeks. Also, give appropriate axes labels, title and keep marker
style as Diamond and marker edge color as ‘red’ for Onion.
SOURCE CODE:
import matplotlib.pyplot as plt Weeks [1,2,3,4]
Onion= [45,25,32,80]
Brinjal=[16,18,45,50]
plt.title("Price Analysis")
plt.xlabel("Weeks")
plt.ylabel("Prices")
plt.plot (Weeks, Onion, marker='D',markersize=15, markeredgecolor='r')
plt.plot(Weeks, Brinjal)
plt.show()
RESULT:
Thus, the above Python program has been executed and verified successfully, and its respective
chart has been generated successfully.
SAMPLE OUTPUT:
***************************************************************************
22
EX.NO: 18
DATE: 25/7/24
PYTHON PROGRAM FOR PLOTTING A BAR CHART FROM A CSV FILE
AIM:
To write a Python program to create a DataFrame for subject-wise average, save it to
a CSV file, and then draw a bar chart using Matplotlib with a width of each bar as 0.25,
specifying different colors for each bar. Additionally, provide a proper title and axes labels for
the bar chart.
SOURCE CODE:
import pandas as pd
import matplotlib.pyplot as plt
DF= pd.DataFrame({'Subject': ['Eng', 'Phy', 'Maths', 'Che', 'IP'],'Sub_Avg': [72,85, 78, 92,
80]),index=['Sub1', 'Sub2','Sub3', 'Sub4','Sub5']) DF.to_csv("D:\\Class 12\\IP\\Subjects.csv")
Data=pd.read_csv("D:\\Class12\\IP\\Subjects.csv")
plt.xlabel("Subjects")
plt.ylabel("Average")
plt.title("Subject Average Analysis")
plt.bar(Data['Subject'],Data['Sub_Avg'],width=0.25,color=['c', 'r','g','b','m'])
plt.show()
RESULT:
Thus, the above Python program has been executed and verified successfully, and its respective
chart has been generated successfully.
SAMPLE OUTPUT:
***************************************************************************
23
EX.NO: 19
DATE: 28/7/24
PYTHON PROGRAM FOR PLOTTING A MULTIPLE BAR CHART FROM A CSV
FILE
AIM:
To write a Python program to plot a multiple bar chart From CSV file using Matplotlib
for subject wise Scores of Class A, Class B, and Class C. Different colors represent each
class, and subjects include English,Accountancy,Economics,BST and IP. Proper labels,
a title and a legend are displayed on the chart.
SOURCE CODE:
RESULT:
Thus, the above Python program has been executed and verified successfully, and its respective
chart has been generated successfully.
SAMPLE OUTPUT:
****************************************************************************
24
EX.NO: 20
DATE: 28/7/24
PYTHON PROGRAM FOR PLOTTING PLOTTING HISTOGRAM
AIM:
To write a Python program to plot a Histogram for the following class interval or range. Also,
give
appropriate axes name, title and edge color as ‘red’.
SOURCE CODE:
import matplotlib.pyplot as plt
Marks [40, 60,55,20,35,70,60,89,20,33] plt.title("Maths Marks-Histogram of class XII")
plt.xlabel("Mark Ranges")
plt.ylabel("No. of Students")
plt.hist (Marks, bins=[0,33,45,60,100], edgecolor='red')
plt.show()
RESULT:
Thus, the above Python program has been executed and verified successfully, and the respective
chart has been generated successfully.
SAMPLE OUTPUT:
***************************************************************************
25
Ex.No: 21
DATE: 23/8/24
SQL COMMANDS EXERCISE – 1
(Basic Queries – I)
AIM:
To write Queries for the following Questions based on the given table:
(e) Write a Query to List all the tables that exists in the current database.
SHOW TABLES;
26
(f) Write a Query to insert all the rows of above table into Info table.
INSERT INTO INFO VALUES (1,'Praveen','M', 25,'Sales','1989-06-8','20000','Chennai');
INSERT INTO INFO VALUES(2,'Arun','M',29,'Marketing','1989-09-6',22000,'Chennai');
INSERT INTO INFO VALUES(3,'Usha','F',27,'Finance','1994-08-09',25000,'Bangalore');
INSERT INTO INFO VALUES(4,'Bala','M',31,'Sales','1990-03-23',27000,NULL);
INSERT INTO INFO VALUES(5,'Rani','F',28,'Marketing','1990-04-23',27000,'Mumbai');
INSERT INTO INFO VALUES (6,'Nisha','F', 26, NULL,'1991-02-24', 18000,'Bangalore');
INSERT INTO INFO VALUES (7,'Manoj','M', 32,'Finance','1982-05-06', 30000,'Goa');
(g) Write a Query to display all the details of the Employees from the above table 'INFO'.
SELECT * FROM INFO;
OUTPUT:
*****************************************************************************
27
Ex.No: 22
DATE: 30/8/24
SQL COMMANDS EXERCISE – 2
(Basic Queries – II)
AIM:
To write Queries for the following Questions based on the given table INFO:
(a) Write a Query to Display Employees’ name and City from the above table.
SELECT NAME, CITY FROM INFO;
(b)Write a Query to Display all details of Employees who are living in Chennai.
SELECT * FROM INFO WHERE CITY='CHENNAI’;
(c)Write a Query to get the name and salary of the employee whose salary is above 15000 and
gender is not male.
*****************************************************************************
29
Ex.No: 23
DATE: 26/9/24
SQL COMMANDS EXERCISE – 3
(Aggregate Functions, Order By Group By, Having Clause)
AIM:
To write Queries for the following Questions based on the given table INFO:
30
Output:
(d) Write a Query to count the number of employees earning more than 25000.
SELECT COUNT(SALARY) FROM INFO WHERE SALARY>25000;
Output:
(e) Write a query to display sum of salary of the employees grouped by department wise.
SELECT DEPT, SUM(SALARY) FROM INFO GROUP BY DEPT;
Output:
(f) Write a query to display the department names where number of employees are greater than
or equal
to 2.
SELECT DEPT FROM INFO GROUP BY DEPT HAVING COUNT(*)>=2;
Output:
*****************************************************************************
31
Ex.No: 24
DATE: 26/9/24
SQL COMMANDS EXERCISE – 4
(Mathematical Functions)
AIM:
To write Queries for the following Questions based on the given table -"STU":
(a) Write a Query to Display square of age that got admission in the month of August.
SELECT POWER(AGE,2) FROM STU WHERE DOA LIKE '%-08-%';
Output:
(c) Write a Query to display Student names and their Percentage in round figure.
SELECT NAME, ROUND(PERCENTAGE,0) FROM STU;
32
Output:
(d) Display Name, Percentage and round up the remainder of percentage up to 2 decimal
places.
SELECT NAME, ROUND(MOD(PERCENTAGE,3),2) FROM STU;
Output:
*****************************************************************************
33
Ex.No: 25
DATE: 27/9/24
SQL COMMANDS EXERCISE – 5
(Text Functions)
AIM:
To write Queries for the following Questions based on the given table -"STU":
(b) Write a Query to display department name and its respective number of characters in Dept
column.
SELECT DEPT,LENGTH(DEPT) FROM STU;
Output:
34
(c) Write a Query to display first 2 characters of the column “Name“
Output:
Output:
(e) Write a query to display the names of all students and extract five characters from the third
position of the 'Name' field.
SELECT SUBSTR(NAME,3,5) FROM STU;
Output:
35
(f) Write a query to display the position of the occurrence of the letter “n” in the column
“Name”
SELECT INSTR(NAME,'n') FROM STU;
Output
*****************************************************************************
36
Ex.No: 26
DATE: 3/10/24
SQL COMMANDS EXERCISE – 6 (Date Functions)
AIM:
To write Queries for the following Questions based on the given table STU:
(a) Write a Query to display student name and month of date of admission of all
students.
SELECT NAME, MONTH(DOA) FROM STU;
Output:
(b) Write a Query to display Student name and day name of the students’ DOA of the
table STU.
SELECT NAME, DAYNAME(DOA) FROM STU;
Output:
37
(c) Write a query to display the joining year of IP students.
SELECT YEAR(DOA) FROM STU WHERE DEPT='IP' ;
Output:
(d) Write a Query to Display the month for the date_of_birth of all students.
SELECT NAME, MONTHNAME(DOA)FROM STU;
Output:
(e) Write a query to display the names of the students who joined in the month of June.
SELECT NAME FROM STU WHERE MONTHNAME(DOA)='June’;
Output:
*****************************************************************************
38
Ex.No: 27
DATE: 4/10/24
SQL COMMANDS EXERCISE – 7 (Equi Join)
AIM:
To write Queries for the following Questions based on the given 2 tables Employee &
Payroll:
Table: Employee
Table: Payroll
Output:
(b) Write the query to display the Employee name and Salary of employees working in Sales
Department
SELECT EMP_NAME,SALARY FROM EMPLOYEE E, PAYROLL P WHERE
E.EMP_ID=P.EMP_ID AND P.DEPARTMENT='SALES';
39
Output:
(c) Write a query to list all designations in the decreasing order of Salary
SELECT DESIGNATION FROM PAYROLL ORDER BY SALARY DESC;
Output:
(d) Write a query to display employee name and their corresponding departments
**************************************************************************
40