0% found this document useful (0 votes)
21 views38 pages

Sample Practical File 2023-2024

Python is a high-level programming language known for its simplicity and readability. It was created by Guido van Rossum and can be used for various purposes like web development, data analysis, artificial intelligence, and more. SQL is a domain-specific language used for managing and querying relational databases and allows users to interact with databases by performing operations like creating, retrieving, updating, and deleting data.

Uploaded by

Arya Vaisshnav
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)
21 views38 pages

Sample Practical File 2023-2024

Python is a high-level programming language known for its simplicity and readability. It was created by Guido van Rossum and can be used for various purposes like web development, data analysis, artificial intelligence, and more. SQL is a domain-specific language used for managing and querying relational databases and allows users to interact with databases by performing operations like creating, retrieving, updating, and deleting data.

Uploaded by

Arya Vaisshnav
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/ 38

INTRODUCTION

Python:
What is Python? Python is a high-level, interpreted programming language known
for its simplicity and readability. It was created by Guido van Rossum and first
released in 1991. Python has gained immense popularity due to its versatility and
wide range of applications.

Key Features:

Easy to Learn: Python's syntax is easy to understand, making it an excellent


language for beginners.
Versatile: Python can be used for various purposes, including web development,
data analysis, artificial intelligence, scientific computing, and more.
Large Standard Library: Python comes with a vast standard library that contains
modules and packages for a wide range of tasks.
Cross-Platform: Python is available for multiple operating systems, including
Windows, macOS, and Linux.
Use Cases:

Web Development: Python is commonly used for web development using


frameworks like Django and Flask.
Data Science and Machine Learning: Libraries like NumPy, pandas, scikit-learn, and
TensorFlow make Python a popular choice for data analysis and machine learning.
Scripting: Python is often used for writing scripts to automate tasks.
Scientific Computing: Scientists and researchers use Python for simulations, data
visualization, and analysis.
Game Development: Python can be used for developing games with libraries like
Pygame.

SQL (Structured Query Language):


What is SQL? SQL is a domain-specific language used for managing and querying
relational databases. It allows users to interact with databases by performing
operations like creating, retrieving, updating, and deleting data.

Key Features:

Data Retrieval: SQL provides powerful commands for retrieving specific data from
databases using queries.
Data Manipulation: It allows for the insertion, updating, and deletion of data within
databases.
Data Definition: SQL can define the structure of a database, including tables,
indexes, and constraints.
Data Control: It provides security and access control mechanisms to protect data.
Use Cases:

Database Management: SQL is used to create, modify, and maintain relational


databases.
Data Analysis: SQL is essential for extracting insights from large datasets stored in
databases.
Business Intelligence: SQL is used in business intelligence tools to generate reports
and dashboards.
Web Development: SQL is integrated with web applications to store and retrieve
data.
Integration of Python and SQL:
Python and SQL can be used together in various applications. Some common
scenarios include:

Database Connectivity: Python can connect to databases like MySQL, PostgreSQL,


or SQLite using libraries like sqlite3, psycopg2, or mysql-connector-python. This
allows Python programs to interact with and manipulate database data.
ORMs (Object-Relational Mapping): Python web frameworks like Django and
SQLAlchemy provide ORM tools that enable developers to work with databases
using Python classes and objects instead of writing raw SQL queries.
Data Analysis: Python can be used to retrieve data from databases, perform data
analysis using libraries like pandas, and visualize results with tools like Matplotlib
or Seaborn.
In summary, Python and SQL are both valuable tools in their respective domains,
and they can complement each other effectively in many real-world applications.
ACKNOWLEDGEMENT

I wish to express my deep gratitude and sincere thanks


to the principal, Dr Sheetal Mann, Modern Convent
School for her encouragement and for all facilities she
provided for this project work. I sincerely appreciate this
magnanimity of hers which she has shown by taking me
into her fold, for which I shall remain indebted to her.
I extend my hearty thanks to Ms Monika Jain (Computer
Science teacher at Modern Convent School) who guided
me to the successful completion of this project. I take
this opportunity to express my deep sense of gratitude
for her invaluable guidance, constant encouragement,
immense motivation which has sustained my efforts at
all stages of my project work.
I cannot forget to offer my profound gratitude to my
parents and my classmates who helped me carry out this
project work successfully. I would also thank them for
their invaluable advice and support which was showered
upon me in the time of need.

THANK YOU
CERTIFICATE

This is to certify that V Arya Vaisshnav of


class 12 has successfully completed the
practical work on Computer Science for
class XII practical examination of the
Central Board of Secondary Education
in the year 2023-24.

It is further certified that this practical


work is the individual work of the
candidate.

Signature
(PGT For Computer Science)
INDEX
Python Programs
1. WRITE A FUNCTION TO SWAP THE VALUES OF TWO VARIABLES THROUGH A FUNCTION.
2. MENU DRIVEN PROGRAM TO PERFORM ARITHMETIC OPERATIONS USING THE CONCEPT OF FUNCTIONS
AND PARAMETERS.
3. PROGRAM TO GENERATE RANDOM NUMBER BETWEEN 1 TO 6.

4. PROGRAM THAT DISPLAY FUNCTIONING OF PARAMETER AND DEFAULT PARAMETERS IN FUNCTION.


5. PROGRAM THAT WILL COUNT THE NUMBER OF ALPHABETS, NUMBERS AND OTHER CHARACTERS IN A
TEXT FILE
6. PROGRAM THAT WILL COUNT THE NUMBER OF WORD “THE “OR “THE “IN A TEXT FILE.
7. PROGRAM THAT WILL COUNT NUMBER OF WORDS STARTS WITH VOWEL.
8. WRITE A CODE THAT READ A TEXT FILE LINE BY LINE AND DISPLAY EACH WORD SEPARATED BY “#”.
9. WRITE A PROGRAM THAT WILL REMOVE ALL THE LINE THAT STARTS WITH ‘A’ AND WRITE IT TO
ANOTHER FILE.
10. PROGRAM TO CREATE BINARY FILE TO STORE ROLLNO AND NAME, SEARCH ANY ROLLNO AND DISPLAY
NAME IF ROLLNO FOUND OTHERWISE “ROLLNO NOT FOUND”
11. WRITE A PROGRAM TO CREATE A BINARY FILE WITH ROLL NO, NAME AND MARKS. INPUT A ROLL
NUMBER AND UPDATE THE MARKS.
12. WRITE A PROGRAM TO CREATE A BINARY FILE BY PUTTING DATA AS DICTIONARY KEYS IN A BINARY FILE
CONDITIONALLY.
13. WRITE A PROGRAM TO CREATE AND READ CSV FILE WITH EMPLOYEE NO, NAME AND SALARY USING
LIST.
14. WRITE A PROGRAM TO WRITE AND DISPLAY A DICTIONARY DATA IN CSV FILE.
15. WRITE A PROGRAM TO IMPLEMENT A STACK USING A LIST DATA-STRUCTURE DEMONSTRATING PUSH()
AND POP() .

SQL (Structured Query Language)

a. CREATE A TABLE STUDENT WITH DUMMY 10 RECORDS AND DISPLAY SELECT, DELETE, UPDATE
OPERATIONS IN MYSQL.

b. QUERIES TO FIND THE AGGREGATE FUNCTIONS LIKE MIN(), MAX(), AVG(), SUM(), COUNT().

c. QUERIES USING DISTINCT, BETWEEN, IN, LIKE, ORDER BY.

d. QUERIES USING HAVING AND GROUP BY.

e. QUERIES USING JOIN.


Python and SQL Connectivity

1. CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON (INSERTING RECORDS AND
DISPLAYING RECORDS)
2. CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON (SEARCHING AND DISPLAYING
RECORDS)
3. CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON (UPDATING RECORDS)
COMPUTER SCIENCE
PRACTICAL EXERCISES 2023-24
CLASS – XII A

EX.NO: 1
DATE:

VALUE OF VARIABLE SWAPPER

AIM:

To write a function to swap the values of the two variables through a function.

Result:

Thus, the above Python program is executed successfully and the output is verified.

SAMPLE OUTPUT:

Python Program Executed Output:


EXP NO: 2

DATE:

MENU DRIVEN PROGRAM TO PERFORM ARITHMETIC OPERATIONS USING THE


CONCEPT OF FUNCTIONS AND PARAMETERS

AIM:
To make a basic arithmetic calculator using the concept of functions and parameters

SOURCE CODE:
SAMPLE OUTPUT:

Result:
Thus, the above Python program is executed successfully and the output is verified
EXP NO. 3

DATE:

CREATING A PROGRAM TO GENERATE RANDOM NUMBER BETWEEN 1 AND 6

AIM:

To wite a program which generates random numbers from 1 to 6 using Random module

SOURCE CODE:

Result:
Thus, the above Python program is executed successfully and the output is verified.

Python Executed Program Output:

EXP NO. 4
DATE:

PROGRAM THAT DISPLAYS FUNCTIONING OF PARAMETER AND DEFAULT PARAMETERS IN


FUNCTION

SOURCE CODE:

Result:
Thus, the above Python program is executed successfully and the output is verified.

Python Executed Program Output:


EXP NO 5

DATE:

CREATING A PROGRAM THAT WILL COUNT THE NUMBER OF ALPHABETS, NUMBERS


AND OTHER CHARACTERS IN A TEXT FILE

SOURCE CODE:

Result:

Thus, the above Python program is executed successfully and the output is verified.

OUTPUT:
EXP NO 6

DATE:
PROGRAM THAT’LL COUNT THE NUMBER OF WORD “THE” OR “the” IN A TEXT FILE

SOURCE CODE:

Result:
Thus, the above Python program is executed successfully and the output is verified.

SAMPLE OUTPUT:
Sample.txt

OUTPUT:

EXP NO 7
DATE:

PROGRAM THAT WILL COUNT THE NUMBER OF WORDS THAT START WITH A VOWEL

SOURCE CODE:

Result:
Thus, the above Python program is executed successfully and the output is verified.

SAMPLE OUTPUT:

EXP NO 8
DATE :

WRITE A CODE THAT READ A TEXT FILE LINE BY LINE AND DISPLAY EACH WORD SEPARATED BY “#”.

SOURCE CODE:

Result:
Thus, the above Python program is executed successfully and the output is verified.
SAMPLE OUTPUT:

SAMPLE.TXT

OUTPUT:

EXP NO 9
DATE:

WRITE A PROGRAM THAT WILL REMOVE ALL THE LINE THAT STARTS WITH ‘A’ AND WRITE IT TO ANOTHER FILE.

SOURCE CODE:

Result:
Thus, the above Python program is executed successfully and the output is verified.

SAMPLE OUTPUT:

INPUT.TXT

OUTPUT.TXT
OUTPUT:

EXP NO 10

DATE
PROGRAM TO CREATE BINARY FILE TO STORE ROLLNO AND NAME, SEARCH ANY ROLLNO AND DISPLAY NAME IF
ROLLNO FOUND OTHERWISE “ROLLNO NOT FOUND”
SOURCE CODE:

Result:
Thus, the above Python program is executed successfully and the output is verified

OUTPUT:
EXP NO 11

DATE

WRITE A PROGRAM TO CREATE A BINARY FILE WITH ROLL NO, NAME AND MARKS. INPUT A ROLL NUMBER AND UPDATE
THE MARKS.

SOURCE CODE:

Result:

Thus, the above Python program is executed successfully and the output is verified

OUTPUT:
EXP NO 12
DATE
WRITE A PROGRAM TO CREATE A BINARY FILE BY PUTTING DATA AS DICTIONARY KEYS IN A BINARY FILE
CONDITIONALLY.
SOURCE CODE:

Result:

Thus, the above Python program is executed successfully and the output is verified

OUTPUT:
EXP NO 13

DATE

WRITE A PROGRAM TO CREATE AND READ CSV FILE WITH EMPLOYEE NO, NAME AND SALARY USING LIST.

SOURCE CODE:

Result:

Thus, the above Python program is executed successfully and the output is verified

OUTPUT:

EXP NO 14
DATE:

WRITE A PROGRAM TO WRITE AND DISPLAY A DICTIONARY DATA IN CSV FILE.

SOURCE CODE:

Result:

Thus, the above Python program is executed successfully and the output is verified

OUTPUT:

EXP NO 15
DATE:

WRITE A PROGRAM TO IMPLEMENT A STACK USING A LIST DATA-STRUCTURE DEMONSTRATING PUSH() AND POP() .

SOURCE CODE:

Result:

Thus, the above Python program is executed successfully and the output is verified

OUTPUT:
SQL (Structured Query Language)

EXP NO 16

DATE:

CREATE A TABLE STUDENT WITH DUMMY 10 RECORDS AND DISPLAY SELECT, DELETE, UPDATE OPERATIONS IN MYSQL.

CODE:

DISPLAY SELECT:
DELETE:

UPDATE:
EXP NO 17

DATE

QUERIES TO FIND THE AGGREGATE FUNCTIONS LIKE MIN(), MAX(), AVG(), SUM(), COUNT().

TABLE:

MIN MARKS CODE:

MAX MARKS CODE:

AVG MARKS CODE:

COUNT(*) AND COUNT(MARKS) CODE:


EXP NO 18

DATE:

QUERIES USING DISTINCT, BETWEEN, IN, LIKE, ORDER BY.

TABLE:

DISTINCT CODE:

BETWEEN CODE:
IN CODE:

LIKE CODE:

ORDER BY CODE:
EXP NO 19

DATE

QUERIES USING HAVING AND GROUP BY.

TABLE:

GROUP BY and COUNT:

GROUP BY and SUM:


GROUP BY, HAVING and AVERAGE:

EXP NO 20

DATE:

QUERIES USING JOIN.

TABLE:
SIMPLE NATURAL JOIN:

INNER JOIN:

LEFT JOIN:

RIGHT JOIN:
Python and SQL Connectivity

EXP 21
DATE

CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON (INSERTING RECORDS AND DISPLAYING RECORDS)

SOURCE CODE:
Result:

Thus, the above Python program is executed successfully and the output is verified.

OUTPUT:
EXP NO 22

DATE

CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON (SEARCHING AND DISPLAYING RECORDS)

SOURCE CODE:

Result:

Thus, the above Python program is executed successfully and the output is verified.

OUTPUT:
EXP NO 23

DATE:

CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON (UPDATING RECORDS)

SOURCE CODE:
Result:

Thus, the above Python program is executed successfully and the output is verified.

OUTPUT:

You might also like