CBSE 2026 results are out, Mukul scored a perfect 100/100 in Computer ScienceSee all toppers →
CBSE Class 12 · Informatics Practices · Practical

CBSE Class 12 Informatics Practices Practical File, Python and SQL with Output

The CBSE Class 12 Informatics Practices (065) practical is 30 marks, and the report file needs both pandas programs and SQL queries. Every one below was executed before publishing — the pandas output is what pandas printed, and the SQL output is what the database returned.

1. Create a pandas Series and print its values and index

Program
import pandas as pd
marks = pd.Series([78, 91, 84, 66], index=["Aarav", "Diya", "Ishaan", "Meera"])
print(marks)
print("Highest:", marks.max(), "scored by", marks.idxmax())
Output
Aarav     78
Diya      91
Ishaan    84
Meera     66
dtype: int64
Highest: 91 scored by Diya

2. Create a DataFrame and show the first rows and shape

Program
import pandas as pd
data = {"Name": ["Aarav", "Diya", "Ishaan", "Meera"],
        "CS": [78, 91, 84, 66],
        "IP": [82, 88, 79, 71]}
df = pd.DataFrame(data)
print(df)
print("Shape:", df.shape)
Output
     Name  CS  IP
0   Aarav  78  82
1    Diya  91  88
2  Ishaan  84  79
3   Meera  66  71
Shape: (4, 3)

3. Add a column and a row to a DataFrame

Program
import pandas as pd
df = pd.DataFrame({"Name": ["Aarav", "Diya"], "CS": [78, 91]})
df["Result"] = ["Pass" if m >= 33 else "Fail" for m in df["CS"]]
df.loc[len(df)] = ["Ishaan", 84, "Pass"]
print(df)
Output
     Name  CS Result
0   Aarav  78   Pass
1    Diya  91   Pass
2  Ishaan  84   Pass

4. Find mean, median and mode of a column

Program
import pandas as pd
df = pd.DataFrame({"Marks": [72, 85, 72, 90, 66]})
print("Mean  :", df["Marks"].mean())
print("Median:", df["Marks"].median())
print("Mode  :", df["Marks"].mode()[0])
Output
Mean  : 77.0
Median: 72.0
Mode  : 72

5. Filter rows of a DataFrame on a condition

Program
import pandas as pd
df = pd.DataFrame({"Name": ["Aarav", "Diya", "Ishaan", "Meera"],
                   "Marks": [78, 91, 45, 66]})
print("Scored 70 or more:")
print(df[df["Marks"] >= 70])
Output
Scored 70 or more:
    Name  Marks
0  Aarav     78
1   Diya     91

6. Write a DataFrame to a CSV file and read it back

Program
import pandas as pd
df = pd.DataFrame({"Name": ["Aarav", "Diya"], "Marks": [78, 91]})
df.to_csv("result.csv", index=False)
back = pd.read_csv("result.csv")
print(back)
Output
    Name  Marks
0  Aarav     78
1   Diya     91

7. Sort a DataFrame and reset the index

Program
import pandas as pd
df = pd.DataFrame({"Name": ["Aarav", "Diya", "Ishaan"], "Marks": [78, 91, 45]})
s = df.sort_values("Marks", ascending=False).reset_index(drop=True)
print(s)
Output
     Name  Marks
0    Diya     91
1   Aarav     78
2  Ishaan     45

8. Group records and find the average per group

Program
import pandas as pd
df = pd.DataFrame({"Section": ["A", "B", "A", "B"],
                   "Marks": [78, 91, 66, 85]})
print(df.groupby("Section")["Marks"].mean())
Output
Section
A    72.0
B    88.0
Name: Marks, dtype: float64

9. SQL: create a table, insert rows and select them

Program
CREATE TABLE student(rollno INTEGER, name TEXT, marks INTEGER);
INSERT INTO student VALUES (1,'Aarav',78),(2,'Diya',91),(3,'Ishaan',45);
SELECT * FROM student;
Output
rollno   name   marks
------  ------  -----
     1  Aarav      78
     2  Diya       91
     3  Ishaan     45

10. SQL: aggregate functions on a table

Program
CREATE TABLE student(rollno INTEGER, name TEXT, marks INTEGER);
INSERT INTO student VALUES (1,'Aarav',78),(2,'Diya',91),(3,'Ishaan',45);
SELECT COUNT(*) AS total, MAX(marks) AS highest,
       MIN(marks) AS lowest, ROUND(AVG(marks),2) AS average FROM student;
Output
total  highest  lowest  average
-----  -------  ------  -------
    3       91      45    71.33

11. SQL: GROUP BY with HAVING

Program
CREATE TABLE emp(name TEXT, dept TEXT, salary INTEGER);
INSERT INTO emp VALUES ('Aarav','Sales',30000),('Diya','Sales',42000),
                       ('Ishaan','IT',55000),('Meera','IT',48000);
SELECT dept, COUNT(*) AS staff, AVG(salary) AS avg_salary
FROM emp GROUP BY dept HAVING COUNT(*) > 1;
Output
dept   staff  avg_salary
-----  -----  ----------
IT         2     51500.0
Sales      2     36000.0

12. SQL: ORDER BY and LIKE

Program
CREATE TABLE student(rollno INTEGER, name TEXT, marks INTEGER);
INSERT INTO student VALUES (1,'Aarav',78),(2,'Diya',91),(3,'Aditi',66);
SELECT name, marks FROM student WHERE name LIKE 'A%' ORDER BY marks DESC;
Output
name   marks
-----  -----
Aarav     78
Aditi     66

Get the full practical-file pack, free

Every program, the exact practical-file format your school expects, and the viva questions that come up most — sent on WhatsApp.

Get it on WhatsApp Book a free demo class

Related: Class 12 IP syllabus · IP 065 weightage · IP sample papers

Stuck on your practical file or the viva?

Kajal Ma'am has been teaching these practicals since 2004. See a real class first — no payment, no commitment.

Book a free demo class

Every program on this page was executed and its output captured from the run. Curated by Kajal Ma'am (MCA), teaching computer subjects since 2004.

Frequently asked questions

What goes in the Class 12 IP practical file?

CBSE Informatics Practices (065) expects pandas programs on Series and DataFrames, data handling with CSV files, plots, and SQL queries including aggregate functions and GROUP BY. The practical is 30 marks: lab test, report file, project and viva.

Do I need MySQL, or will SQLite do?

The SQL on this page is standard and runs on both. Your school will normally specify MySQL, and the same statements work there — CREATE TABLE, INSERT, SELECT, GROUP BY and HAVING are identical for this syllabus.

Can I get the full pack with the file format?

Yes — ask on WhatsApp and Kajal Ma'am's team will send the programs, the practical file format your school expects, and the viva questions that come up most.

{ }

Frequently asked questions

How many programs are needed in the CBSE Class 12 CS practical file?+
As per CBSE, the report file should contain a minimum of 15 Python programs and 5 sets of SQL queries. The practical is 30 marks (lab test 12, report file 7, project 8, viva 3).
Are these programs part of the CBSE syllabus?+
Yes, these are standard CBSE Class 12 Computer Science (083) practical concepts: stacks, file handling, recursion, searching, dictionaries and Python-MySQL connectivity. Every program here has been run and its output verified.
Can I get the full practical file and viva questions?+
Yes, request the full pack (15+ programs, the CBSE practical-file format and likely viva questions) on WhatsApp, free. Kajal Ma'am's team can also guide you through your own file.

Want to ace your boards?

See a real class before you decide. No pressure, no payment.

Book Free Demo on WhatsApp

Studying outside India?

We coach CBSE, IGCSE & international students across the globe, one-to-one, in your local time zone.

Visit International →