This article provides fully solved answers with Python (Pandas & Matplotlib) and SQL queries for the SSCE Practical Examination – Class 12 Informatics Practices (065) Solution. These solutions follow CBSE/State Board practical standards and help students score maximum marks.
Topics Covered
Q1: Python with Pandas and Matplotlib (Scooter Data Analysis)
File name: scooter.csv
| ScooterID | ScooterName | Price | Company | Qty |
|---|---|---|---|---|
| S001 | Activa 6 G | 78000 | Honda | 18 |
| S002 | NTorq | 88000 | TVS | 43 |
| S003 | Jupiter | 77000 | TVS | 17 |
| S004 | Access | 82000 | Suzuki | 24 |
| S005 | Burgman | 95000 | Suzuki | 26 |
(a) Read CSV file and create Pandas DataFrame. [2]
(b) Display scooter names and price where quantity is less than 30. [1]
(c) Display top 3 records from the dataframe. [1]
(d) Display scooter details manufactured by TVS and Suzuki [1]
(e) Display the number of rows and columns of dataframe. [1]
(f) Draw a line chart which represent scooter name on x-axis and price on y-axis. Label the chart properly and display legends. [2]
Solution
import pandas as pd
# Ans. (a)
df = pd.read_csv("scooter.csv")
print(df)
# Ans. (b)
#Using Loc
print(df.loc[df['Qty'] < 30, ['ScooterName', 'Price']])
#Using Index
df[df['Qty'] < 30][['ScooterName', 'Price']]
#Using Query method
df.query("Qty < 30")[['ScooterName', 'Price']]
#Using Filter
df[df['Qty'] < 30].filter(['ScooterName', 'Price'])
#Using where
df[['ScooterName', 'Price']].where(df['Qty'] < 30).dropna()
#Ans. (c)
#Using head function
print(df.head(3))
#Using iloc
df.iloc[:3]
#Using loc
df.loc[0:2]
#Ans. (d)
#Using | operator
df[(df['Company'] == 'TVS') | (df['Company'] == 'Suzuki')]
#Using isin() function
print(df[df['Company'].isin(['TVS', 'Suzuki'])])
#Using query method
df.query("Company == 'TVS' or Company == 'Suzuki'")
#Using loc
df.loc[(df['Company'] == 'TVS') | (df['Company'] == 'Suzuki')]
#Ans (e)
#Using shape
print("Rows:", df.shape[0])
print("Columns:", df.shape[1])
#Using len() function
print("Rows:", len(df))
print("Columns:", len(df.columns))
#Ans (f)
import matplotlib.pyplot as plt
plt.plot(df['ScooterName'], df['Price'], marker='o', label='Scooter Price')
plt.xlabel("Scooter Name")
plt.ylabel("Price")
plt.title("Scooter Price Comparison")
plt.legend()
plt.show()
Q2: SQL Queries on Store Table
Table:Store
| Stid | Name | City | Noofemployee | Dateopened | Salesamount |
|---|---|---|---|---|---|
| S101 | India mart | Delhi | 12 | 2020-05-18 | 340000 |
| S102 | Super market | Mumbai | 20 | 2021-08-22 | 390000 |
| S103 | Planetorium | Delhi | 17 | 2019-02-14 | 240000 |
| S104 | Gulnaz | Delhi | 10 | 2022-04-01 | 180000 |
| S105 | Libaas | Mumbai | 8 | 2020-11-24 | 20000 |
- Create the above given table with appropriate data type and constraints. [1]
- Display Name and city of the store open in year 2020. [1]
- Count the store in different city. [1]
- Display the table details in ascending order of salesamount. [1]
- Display the total noofemployees for stores in each city. [1]
- Calculate the discount value for all bikes as 8% of salesamount. [1]
- Display the stores open in the month of August. [1]
Solution
Ans.: (a)
CREATE TABLE Store (
Stid VARCHAR(5) PRIMARY KEY,
Name VARCHAR(30),
City VARCHAR(20),
Noofemployee INT,
Dateopened DATE,
Salesamount INT
);
Ans. (b)
SELECT Name, City
FROM Store
WHERE YEAR(Dateopened) = 2020;
Ans. (c)
SELECT City, COUNT(*) AS TotalStores
FROM Store
GROUP BY City;
Ans. (d)
SELECT *
FROM Store
ORDER BY Salesamount ASC;
Ans. (e)
SELECT City, SUM(Noofemployee) AS TotalEmployees
FROM Store
GROUP BY City;
Ans. (f)
SELECT Name, Salesamount, Salesamount * 0.08 AS Discount
FROM Store;
Ans. (g)
SELECT *
FROM Store
WHERE MONTH(Dateopened) = 8;
Q3: Practical File [5 Marks]
Marks awarded based on:
- Proper record work
- Correct programs
- Output screenshots
- Index and teacher signature
Q4: Project work [5 Marks]
Marks based on:
- Project objective
- Use of Pandas/CSV
- Screenshots and outputs
- Viva explanation
Q5: Viva-Voce [5 Marks]
Students may be asked:
- Difference between DataFrame and Series
- Use of
GROUP BY - Meaning of primary key
- CSV vs database
- Plot types in Matplotlib
Conclusion
This article provides complete, accurate, and exam-ready solutions for the SSCE Informatics Practices Practical Exam.
Students should practice writing these answers by hand and execute code practically to score full marks.