IP Practical
IP Practical
Class 12
Submitted by:
Name: Palak Saha
Class: 12 A
Class Roll: 05
Board Roll:
Admission no: 8878
Submitted to: Mr. Servesh Kumar(IP teacher)
Date ____________________
1
CERTIFICATE
This is to certify that PALAK SAHAJ, student of Class XII, DAV PUBLIC
SCHOOL malighat has completed the the academic year 2024-2025
towards partial fulfillment of credit of the Informatics Practices project
evaluation of CBSE and submitted a satisfactory report, as compiled in the
following pages, under supervision.
_______________________________ ________________________________
Internal Examiner Signature Principle seal and signature
_______________________________ ________________________________
External Examiner Signature Head of Department Signature
2
ACKNOWLEDGEMENT
I also extend to thank my teachers and my class mate and friends who help
me comple this project successfully.
3
INDEX
1. Data Handling
1.1. Create a Pandas Series from a Dictionary of Values and a Numpy ndarray
1.6. Importing and Exporting Data Between Pandas and CSV File
2. Visualization
2.1. Analyze Employee Salary Distribution
4
Data Handling and Visualization Project for Class 12 CBSE
In this project, we will explore various data handling techniques using the pandas
library, perform data visualization using matplotlib, and manage data using SQL
queries in a MySQL database. Each section includes code snippets, detailed
explanations, related content, and expected outputs.
1. Data Handling
1.1. Create a Pandas Series from a Dictionary of Values and a Numpy ndarray
Overview: A Pandas Series allows for easy manipulation and analysis of one-
dimensional data. It can be thought of as a more powerful version of a list or array, with
added functionalities such as labels (indices) and built-in methods for operations.
Technical Details: - The pandas library is essential for data manipulation and analysis.
- A dictionary can be transformed into a Series where keys become indices, and values
become data points.
Code:
import pandas as pd
import numpy as np
5
Expected Output:
Subject Scores Series:
Math 85
English 90
Science 75
History 80
dtype: int64
6
Expected Output:
Scores above the 70th percentile:
5 90
6 95
dtype: int64
Expected Output:
Total sales expenditure per category:
Category
Accessories 100
Electronics 2600
Wearables 200
Name: Expenditure, dtype: int64
7
1.4. Create a DataFrame for Student Results
Overview: Managing student results is a common application of DataFrames. In this
section, we create a DataFrame to store student results, including attributes like student
ID, name, and grades. This showcases how to organize and analyze student performance
data.
Technical Details: - DataFrames can be easily manipulated using indexing and filtering.
- Methods such as dtypes and shape provide insights into the structure of the
DataFrame.
Code:
import pandas as pd
Expected Output:
Row Labels: [0, 1, 2]
Column Labels: ['Student ID', 'Name', 'Grade']
Data Types:
Student ID int64
Name object
Grade object
dtype: object
Dimensions: (3, 3)
8
Code:
import pandas as pd
Expected Output:
DataFrame after removing duplicates:
Name Score
0 Alice 95
1 Bob 85
3 Charlie 90
1.6. Importing and Exporting Data Between Pandas and CSV File
Overview: Data import and export are essential for data manipulation, allowing for
seamless data transfer between formats. This section illustrates how to export a
DataFrame to a CSV file and subsequently import it back into a DataFrame.
Technical Details: - The to_csv() method is used to write the DataFrame to a CSV file.
- The read_csv() method allows for reading CSV files into DataFrames, supporting
various options for data parsing.
Code:
import pandas as pd
employees_df = pd.DataFrame(data)
9
Expected Output:
Imported Employees DataFrame:
Employee ID Name Salary
0 1 Alice 70000
1 2 Bob 80000
2 3 Charlie 60000
2. Visualization
2.1. Analyze Employee Salary Distribution
Overview: Data visualization is crucial for interpreting and presenting data insights
effectively. This section analyzes employee salaries by creating a histogram to visualize
the distribution of salaries among employees.
Technical Details: - A histogram provides a visual representation of the distribution of
numerical data. - The hist() function in Matplotlib is utilized for creating the
histogram.
Code:
import pandas as pd
import matplotlib.pyplot as plt
10
Code:
import pandas as pd
import matplotlib.pyplot as plt
plt.hist(ages,bins=20)
plt.title('Participants’ ages Histogram ')
plt.show()
11
3. Data Management with MySQL
3.1. Create a Products Table in MySQL
Overview: In relational databases, tables are fundamental structures used to store data.
This section outlines how to create a Products table in a MySQL database to manage
product information.
Technical Details: - The CREATE TABLE statement is used to define the structure of the
table, including the data types for each column.
Code:
CREATE TABLE IF NOT EXISTS Products (
ProductID INT PRIMARY KEY,
ProductName VARCHAR(100),
Price DECIMAL(10, 2));
Expected Output: Table created successfully (no direct output from SQL command).
Technical Details: - The INSERT INTO statement adds new rows to the table,
specifying values for each column.
Code:
INSERT INTO Products (ProductID, ProductName, Price) VALUES (1,
'Laptop', 1500.00);
INSERT INTO Products (ProductID, ProductName, Price) VALUES (2,
'Smartphone', 800.00);
INSERT INTO Products (ProductID, ProductName, Price) VALUES (3,
'Tablet', 300.00);
Expected Output: New records inserted successfully (no direct output from SQL
command).
12
Expected Output: Product deleted successfully (no direct output from SQL command).
Expected Output:
+-----------+--------------+--------+
| ProductID | ProductName | Price |
+-----------+--------------+--------+
| 1 | Laptop | 1500.00|
| 3 | Tablet | 300.00 |
+-----------+--------------+--------+
Technical Details: - The SUM() aggregate function computes the total of a specified
column.
Code:
SELECT SUM(Price) AS TotalPrice FROM Products;
Expected Output:
+-----------+
| TotalPrice|
+-----------+
| 1800.00 |
+-----------+
13
Technical Details: - The CASE statement in SQL can be used to categorize data for
aggregation.
Code:
SELECT
CASE
WHEN Price < 500 THEN 'Under 500'
WHEN Price >= 500 AND Price < 1000 THEN '500 to 999'
ELSE '1000 and above'
END AS PriceRange,
COUNT(*) AS ProductCount
FROM Products
GROUP BY PriceRange;
Expected Output:
+-------------+-------------+
| PriceRange | ProductCount|
+-------------+-------------+
| 1000 and above| 2 |
| 500 to 999 | 1 |
+-------------+-------------+
Expected Output:
+-----------+--------------+--------+
| ProductID | ProductName | Price |
+-----------+--------------+--------+
| 1 | Laptop | 1500.00|
| 3 | Tablet | 300.00 |
+-----------+--------------+--------+
14
CONCLUSION
This project provides a comprehensive overview of data handling, visualization, and
management using Python, pandas, and MySQL. Each section is designed to be self-
contained, ensuring that all necessary imports and connections are included. By
following this project, students gain practical experience in analyzing, manipulating, and
visualizing data, which are essential skills in today’s data-driven world. This project
promotes critical thinking and problem-solving abilities, and fosters a deeper
understanding of how to work with data effectively.
15