0% found this document useful (0 votes)
4 views22 pages

Practical File

The document is a practical file for Aditya Kashyap, a Class 12-B student at Ryan International School, detailing his completed Computer Science practicals for the academic year 2025-26. It includes a certification of completion, an index of practicals covering Python programming, MySQL queries, and database connectivity. The practicals consist of various programming tasks such as menu-driven programs, file handling, and database operations, totaling 24 certified practicals.

Uploaded by

Aditya Kashyap
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)
4 views22 pages

Practical File

The document is a practical file for Aditya Kashyap, a Class 12-B student at Ryan International School, detailing his completed Computer Science practicals for the academic year 2025-26. It includes a certification of completion, an index of practicals covering Python programming, MySQL queries, and database connectivity. The practicals consist of various programming tasks such as menu-driven programs, file handling, and database operations, totaling 24 certified practicals.

Uploaded by

Aditya Kashyap
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/ 22

Aditya Kashyap Class – 12th B CS Practical file

PRACTICAL FILE
Computer Science
Subject Code: 083
Class 12-B
Session: 2025-26

Ryan Internation School Greater


Noida, Uttar Pradesh
Roll No: 03
Name of Student: Aditya Kashyap
Class: 12-B
Subject: Computer Science(083)
School: Ryan International School
Aditya Kashyap Class – 12th B CS Practical file

CERTIFICATE

This is to certify that Aditya Kashyap, a


student of class 12, section B of Ryan
International School has successfully
completed and submitted the practical file of
Computer Science(083) as per the guidelines
provided by CBSE in the prescribed curriculum
for academic year 2025-26 for accomplishment
of Senior School Certificate Examination –
2026.
The practical file has been evaluated and
found correct in accordance with the
guidelines provided by the board for academic
year 2025-26. The work has been completed and
presented in a satisfactory manner.
No. of practicals certified are: 24

Internal Examiner External


Examiner
Aditya Kashyap Class – 12th B CS Practical file

School Stamp Principal

INDEX
Part A – Python Programs:
Python Revision tour:
1) List Menu Driven Program
2) Dictionary Menu Dirven Program
Working with Functions:
3) Using a function to display prime
numbers between m & n
4) Using a function to calculate interest
using various arguments.
5) Using a function to find the largest
element in a list. Pass the list object as
argument
6) Using a function to count the numbers
of vowels in passed string
Exception Handling:
7) Take two integers and perform addition
of two numbers to handle exception when
non-integers entered by user
8) Find the square root of a positive
number, raise a custom exception when user
enters a negative number.
File Handling:
9) Find and replace a word in a text file
Aditya Kashyap Class – 12th B CS Practical file

10) Menu driven program for binary file to


insert, update, delete, and display records
11) Menu driven program for csv file to
insert, update, and delete records
12) Search record in binary file using user
defined condition
13) Search record in csv file using defined
condition
Data Structure – Stack:
14) Menu driven program for stack
operations
15) Searching data from dictionary and
transfer keys into stack then performing
push operations

Part B – Python Programs:


16) Set 1 – Based on Database basic
commands
17) Set 2 – Based on DDL commands
18) Set 3 – Select Queries including order
by
19) Set 4 – Group by, having and aggregate
functions
20) Set 5 - Join Queries

Part C – Python Database


Connectivity:
21) Insert record in a database table
Aditya Kashyap Class – 12th B CS Practical file

22) Update a record in a database table


23) Delete a record in a database table
24) Display records using queries from
database table

PART B – MySQL Queries


Chapter 07 – Relational Database in
SQL
Set 1 – Based on database basic commands
Write SQL commands for following:
1) Create a database named practical_26.

CREATE DATABSE practical_26;

2) Check database is present or not in


the list of databases.

SHOW DATABASES;
Aditya Kashyap Class – 12th B CS Practical file

3) Open a database.

USE practical_26;

4) Create a database employee.

CREATE DATABASE employee;

5) Delete a database employee.

DROP DATABASE employee;

Set 2 – Based on DDL commands


Consider the following GAMES table and write
the SQL commands based on it.
Aditya Kashyap Class – 12th B CS Practical file

1) Create above table, assign Game_ID as


primary key and insert records as above.

CREATE TABLE Games(Game_ID VARCHAR(4)


PRIMARY KEY, Game_Name VARCHAR(20), Type
VARCHAR(20), R_Date DATE, Rating INT);

INSERT INTO Games VALUES(‘G01’, ‘GTA6’,


‘Open World’, 26/06/26, 5);
Similarly add other records too.

2) Show the structure of the table.


Aditya Kashyap Class – 12th B CS Practical file

DESC Games;

3) Add a column named Console.

ALTER TABLE Games ADD COLUMN Console;

4) Change the data of Game_ID to varchar.

ALTER TABLE Games MODIFY COLUMN Game_ID


varchar(3);
Aditya Kashyap Class – 12th B CS Practical file

5) Rename a column Game_Name to G_Name.

ALTER TABLE Games RENAME COLUMN Game_Name


TO G_Name;

6) Delete column Console.

ALTER TABLE Games DROP COLUMN Console;

Set 3 – Select Queries including order by


1) Display the game name, type, release
date and rating of all games.

SELECT G_Name, Type, R_Date, Rating FROM


Games;
Aditya Kashyap Class – 12th B CS Practical file

2) Display all details of action and open


world games.

SELECT * FROM Games WHERE Type == ‘Action’


OR Type = ‘Open World’;

3) Display the details of games where


G_Name starts with letter G.

SELECT * FROM Games WHERE G_Name like ‘G%’;

4) Display the game name, type and rating


in the descending order of rating.
Aditya Kashyap Class – 12th B CS Practical file

SELECT G_Name, Type, Rating FROM Games


ORDER BY Rating DESC;

Set 4 – Group by, having clause and aggregate


functions
1) Display the number of games for each
type.

SELECT Type, count(*) FROM Games GROUP BY


Type;

2) Display the number of unique movies.

SELECT COUNT(DISTINCT Type) FROM Games;


Aditya Kashyap Class – 12th B CS Practical file

3) Display the maximum production cost


for each game type.

SELECT Type, MAX(Rating) FROM Games GROUP


BY Type;

4) Display the average rating of Games


for each type.

SELECT Type, AVG(Rating) FROM Games GROUP


BY Type;

Set 5 – Join Queries


Aditya Kashyap Class – 12th B CS Practical file

Create two tables as follows and write given


queries below:
Table Artist:

Table Songs:

1) Display the cartesian product of


Artist and Songs table.

SELECT * FROM Artist, Songs;


Aditya Kashyap Class – 12th B CS Practical file

2) Display the records of Artist and


Songs using equijoin.
SELECT * FROM Artist, Songs WHERE
Artist.A_id = Songs.S_id;

3) Display the records of Artist and


Songs tables using natural join.

SELECT * FROM Artist NATURAL JOIN Songs;


Aditya Kashyap Class – 12th B CS Practical file

Part C – Python & MySQL Connectivity


Programs
Chapter 14 – Interface Python with
MySQL
1) Write a program to connect with mysql
database and insert a record into database.
2) Write a program to connect with MySQL
database and update a record into database.
3) Write a program to connect with MySQL
database and delete a record into database.
4) Write a program to connect with MySQL
database display record of particular label
under the artist is working.

# Importing MySQL connector


import mysql.connector

# Function to display menu


def menu():
print("\n ~ V I D . G A M E S ~")
Aditya Kashyap Class – 12th B CS Practical file

print("1 -> Create table Game")


print("2 -> Insert rows")
print("3 -> Display Games")
print("4 -> Search Game")
print("5 -> Update Game")
print("6 -> Delete Game")
print("7 -> Update Sold Status")
print("8 -> Exit from the program")

# Function to read user choice


def rChoice():
c = int(input("Enter your choice: "))
return c

# Function to create connection


def Create_Conct():
mydb = mysql.connector.connect(
host='localhost',
user='root',
passwd='Aditya@2008',
database='project_26_2'
)
cursor = mydb.cursor()
return mydb, cursor

# Function to create table


def Create_T():
mydb, cursor = Create_Conct()
strSQL = """
CREATE TABLE IF NOT EXISTS Game (
G_No INT(3) PRIMARY KEY,
G_Name VARCHAR(20),
Aditya Kashyap Class – 12th B CS Practical file

Price INT,
Rating INT(2),
Sold VARCHAR(3) DEFAULT 'NO'
);
"""
cursor.execute(strSQL)
print("Table created successfully or
already exists.")
mydb.close()

# Function to insert rows


def Insert_R():
G_No = int(input("Enter Game number:
"))
G_Name = input("Enter Game name: ")
Price = int(input("Enter Price: "))
Rating = int(input("Enter Rating: "))
Sold = input("Is the game sold?
(YES/NO): ").strip().upper()

if Sold not in ["YES", "NO"]:


print("Invalid value for Sold.
Defaulting to 'NO'.")
Sold = "NO"

mydb, cursor = Create_Conct()


strSQL = "INSERT INTO Game VALUES (%s,
%s, %s, %s, %s);"
values = (G_No, G_Name, Price, Rating,
Sold)
cursor.execute(strSQL, values)
mydb.commit()
Aditya Kashyap Class – 12th B CS Practical file

print("Record inserted successfully.")


mydb.close()

# Function to show table


def Show_T():
#Used to display the table
mydb, cursor = Create_Conct()
strSQL = "SELECT * FROM Game;"
cursor.execute(strSQL)
r = cursor.fetchall()
for i in r:
print(i)
mydb.close()

# Function to search for a game


def Search():
G_Name = input("Enter Game name to
search: ")
mydb, cursor = Create_Conct()
strSQL = "SELECT * FROM Game WHERE
G_Name = %s;"
cursor.execute(strSQL, (G_Name,))
records = cursor.fetchall()

if not records:
print(f"{G_Name} not found.")
else:
print(f"{G_Name} FOUND:")
print("Details:")
for row in records:
print(row)
mydb.close()
Aditya Kashyap Class – 12th B CS Practical file

# Function to delete a game


def Delete():
G_No = int(input("Enter Game number to
delete: "))
mydb, cursor = Create_Conct()
strSQL = "DELETE FROM Game WHERE G_No =
%s;"
cursor.execute(strSQL, (G_No,))
mydb.commit()

if cursor.rowcount == 0:
print("No such game found.")
else:
print("Game deleted successfully.")
mydb.close()

# Function to update a game


def Update():
G_No = int(input("Enter Game number to
update: "))
print("1 -> Update Game Name")
print("2 -> Update Price")
print("3 -> Update Rating")
choice = int(input("Enter your choice:
"))

mydb, cursor = Create_Conct()

if choice == 1:
new_name = input("Enter new Game
Name: ")
Aditya Kashyap Class – 12th B CS Practical file

cursor.execute("UPDATE Game SET


G_Name = %s WHERE G_No = %s;", (new_name,
G_No))
elif choice == 2:
new_price = int(input("Enter new
Price: "))
cursor.execute("UPDATE Game SET
Price = %s WHERE G_No = %s;", (new_price,
G_No))
elif choice == 3:
new_rating = int(input("Enter new
Rating: "))
cursor.execute("UPDATE Game SET
Rating = %s WHERE G_No = %s;", (new_rating,
G_No))
else:
print("Invalid choice.")
mydb.close()
return

mydb.commit()
print("Game details updated
successfully.")
mydb.close()

# Function to update Sold status


def Update_Sold():
G_No = int(input("Enter Game number to
update Sold status: "))
new_sold = input("Enter new Sold status
(YES/NO): ")
Aditya Kashyap Class – 12th B CS Practical file

if new_sold not in ["YES", "NO"]:


print("Invalid input. Please enter
YES or NO.")
return

mydb, cursor = Create_Conct()


cursor.execute("UPDATE Game SET Sold =
%s WHERE G_No = %s;", (v))
mydb.commit()

v = (new_sold, G_No)

if cursor.rowcount == 0:
print("No such game found.")
else:
print("Sold status updated
successfully.")
mydb.close()

# MAIN PROGRAM
while True:
menu()
c = rChoice()
if c == 1:
Create_T()
elif c == 2:
Insert_R()
elif c == 3:
Show_T()
elif c == 4:
Search()
elif c == 5:
Aditya Kashyap Class – 12th B CS Practical file

Update()
elif c == 6:
Delete()
elif c == 7:
Update_Sold()
elif c == 8:
print("Exiting program...")
break
else:
print("WRONG CHOICE")

You might also like