CS Practical File
CS Practical File
INDEX
S.NO. TOPIC PAGE
NO.
1 8
To write a menu driven Python Program to perform
Arithmetic operations (+,-*,/) based on the user’s choice.
5 15
To write a Python program to implement python mathematical
functions to find:
10 21
To write a python program to read lines from a text file
"Sample.txt" and copy those lines into another file which
are starting with an alphabet 'a' or 'A'.
11 To write a Python Program to Create a binary file 22
with roll number and name. Search for a given roll
number and display the name, if not found display
appropriate message.
13 26
To write a Python program Create a CSV file to store
Empno, Name, Salary and search any Empno and display
Name, Salary and if not found display appropriate
message.
20
To write Queries for the following Questions based on the given
table:
40
TABLE: COST
CERTIFICATE
This is to certify that Sourav Dahiya, of class
XII B of RYAN INTERNATIONAL SCHOOL has
completed his Practical File under my
supervision. He has taken interest and
shown utmost sincerity in the completion of
this. I certify this Practical File up to my
expectations and as per the guidelines issued
by CBSE, NEW DELHI.
PRINCIPAL
ACKNOWLEDGEMENT
It is with great pleasure that I express my sincere
gratitude to Ms. Ritu Dawar, our teacher, for her
valuable guidance and support throughout the
development of this project. Her dedication to teaching
and her constant encouragement have been a source of
inspiration not only for me but for all students. I have
greatly benefited from her classes and guidance.
I am deeply indebted to Ms. Mamta Nanda, our
Principal, whose continuous encouragement and
support have played a pivotal role in the success of this
project. Without her inspiration and belief in my
abilities, this project would not have been possible. I
extend my heartfelt thanks to her for her unwavering
support.
Lastly, I would like to express my sincere appreciation
to all my batch-mates for their friendship and for the
unforgettable moments we shared together. Their
presence has made this journey enjoyable and
memorable.
Page |7
Hardware Requirements:
• Processor: Intel Core i3 or equivalent
• RAM: 4 GB (8 GB recommended)
• Storage: 50 MB free disk space
• Display: 1024x768 resolution
• Input: Keyboard and Mouse
• OS: Windows 7 or higher, macOS, or Linux
Software Requirements:
• Programming Language: Python 3.6 or higher
• Libraries: datetime, csv, os, random
• IDE: Visual Studio Code, PyCharm, or any Python
IDE
• Database: CSV files for data storage
EX.NO: 1
DATE:
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
Page |9
SAMPLE OUTPUT:
***************************************************************************************
EX.NO: 2
DATE:
CREATING A PYTHON PROGRAM TO DISPLAY FIBONACCI SERIES
AIM:
To write a Python Program to display Fibonacci Series up to ‘n’ numbers.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
P a g e | 11
SAMPLE OUTPUT:
Python Executed Program Output:
*****************************************************************************************
EX.NO: 3
DATE:
AIM:
To write a menu driven Python Program to find Factorial and sum of list of numbers
using function.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
P a g e | 13
SAMPLE OUTPUT:
************************************************************************************************
EX.NO: 4
DATE:
AIM:
To Write a Python program to define the function Check(no1,no2) that take two numbers and
Returns the number that has minimum ones digit.
Source Code:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
Sample Output:
**********************************************************************************
P a g e | 15
EX.NO: 5
DATE:
AIM:
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
SAMPLE OUTPUT:
Python Executed Program Output:
***************************************************************************
EX.NO: 6
DATE:
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
SAMPLE OUTPUT:
**********************************************************************************
P a g e | 17
EX.NO: 7
DATE:
AIM:
To write a Python Program to Read a text file "Story.txt" line by line and display
each word separated by '#'.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
SAMPLE OUTPUT:
Story.txt:
EX.NO: 8
DATE:
To write a Python Program to read a text file "Story.txt" and displays the number of
Vowels/ Consonants/ Lowercase / Uppercase/characters in the file.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
P a g e | 19
SAMPLE OUTPUT:
Story.txt:
***************************************************************************************
EX.NO: 9
DATE:
AIM:
To Write a method Disp() in Python, to read the lines from poem.txt and display those
words which are less than 5 characters.
Source Code:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
Sample Output:
Poem.txt:
**********************************************************************************
P a g e | 21
EX.NO: 10
DATE:
To write a python program to read lines from a text file "Sample.txt" and copy those lines
into another file which are starting with an alphabet 'a' or 'A'.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
SAMPLE OUTPUT:
New.txt:
*****************************************************************************************
EX.NO: 11
DATE:
AIM:
To write a Python Program to Create a binary file with roll number and name.
Search for a given roll number and display the name, if not found display appropriate
message.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
P a g e | 23
SAMPLE OUPUT:
*******************************************************************************************
EX.NO: 12
DATE:
To write a Python Program to Create a binary file with roll number, name, mark
and update/modify the mark for a given roll number.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
P a g e | 25
SAMPLE OUTPUT:
**********************************************************************************
EX.NO: 13
DATE:
AIM:
To write a Python program Create a CSV file to store Empno, Name, Salary and search any Empno
and display Name, Salary and if not found display appropriate message.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
P a g e | 27
SAMPLE OUTPUT:
******************************************************************************
EX.NO: 14
DATE:
AIM:
To write a Python program to implement Stack using a list data-structure, to perform
(i) To Push an object containing Doc_ID and Doc_name of doctors who specialize
in "ENT" to the stack.
(ii) To Pop the objects from the stack and display them.
(iii) To display the elements of the stack (after performing PUSH or POP)
SOURCE CODE:
P a g e | 29
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
SAMPLE OUTPUT:
Python Program Executed Output:
****************************************************************************************
P a g e | 31
EX.NO: 15
DATE:
AIM:
To Write a program, with separate user-defined functions to perform the following
operations:
(iv) To Create a function Push(Stk,D) Where Stack is an empty list and D is Dictionary of
Items. from this Dictionary Push the keys (name of the student) into a stack,
where the corresponding value (marks) is greater than 70.
(v) To Create a Function Pop(Stk) , where Stk is a Stack implemented by a list of student
names. The function returns the items deleted from the stack.
(vi) To display the elements of the stack (after performing PUSH or POP).
Source Code:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
Sample Output:
*********************************************************************************
P a g e | 33
EX.NO: 16
DATE:
CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON
(CREATING DATABASE AND TABLE)
AIM:
To write a Python Program to integrate MYSQL with Python to create Database and Table
to store the details of employees.
Source Code:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
Sample Output:
******************************************************************************************************
P a g e | 35
EX.NO: 17
DATE:
CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON
(INSERTING RECORDS AND DISPLAYING RECORDS)
AIM:
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
SAMPLE OUTPUT:
******************************************************************************************************************************************************************************
P a g e | 37
EX.NO: 18
DATE:
CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON
(SEARCHING AND DISPLAYING RECORDS)
AIM:
To write a Python Program to integrate MYSQL with Python to search an Employee using
EMPID and display the record if present in already existing table EMP, if not display the
appropriate message.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
SAMPLE OUTPUT:
To write a Python Program to integrate MYSQL with Python to search an Employee using
EMPID and update the Salary of an employee if present in already existing table
EMP, if not display the appropriate message.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
P a g e | 39
SAMPLE OUTPUT:
**************************************************************************************************************************************************
SQL COMMANDS EXERCISE - 1
Ex.No: 20
DATE:
AIM:
To write Queries for the following Questions based on the given table:
USE STUDENTS;
SHOW DATABASES;
(e) Write a Query to List all the tables that exists in the current database.
SHOW TABLES;
Output:
P a g e | 41
AIM:
To write Queries for the following Questions based on the given table:
(a) Write a Query to insert all the rows of above table into Info table.
(b) Write a Query to display all the details of the Employees from the above table 'STU'.
Output:
(c) Write a query to Rollno, Name and Department of the students from STU table.
Output:
Output:
********************************************************************************************
P a g e | 43
DATE:
AIM:
To write Queries for the following Questions based on the given table:
Output:
(b) Write a Query to list name of the students whose ages are between 18 to 20.
Output:
(c) Write a Query to display the name of the students whose name is starting with 'A'.
Output:
(d) Write a query to list the names of those students whose name have second alphabet 'n' in their
names.
Output:
**********************************************************************************************************
39
P a g e | 45
DATE:
AIM:
To write Queries for the following Questions based on the given table:
(b) Write a Query to change the fess of Student to 170 whose Roll number is 1, if the existing fess
is less than 130.
Output(After Update):
(c) Write a Query to add a new column Area of type varchar in table STU.
Output:
(d) Write a Query to Display Name of all students whose Area Contains NULL.
Output:
(e) Write a Query to delete Area Column from the table STU.
Output:
Output:
*******************************************************************************************
Ex.No: 24 SQL COMMANDS EXERCISE - 5
DATE:
AIM:
To write Queries for the following Questions based on the given table:
TABLE: UNIFORM
TABLE: COST
(a) To Display the average price of all the Uniform of Raymond Company from table COST.
Output:
(b) To display details of all the Uniform in the Uniform table in descending order of Stock date.
Output: