Final Cs Lab Manual
Final Cs Lab Manual
AIM:
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the
output is verified successfully.
SAMPLE OUTPUT:
Python Executed Program output:
Sample.txt
*********************************************************************************
2) Creating Python Program to define a function to write and read a text file and display the
number of vowels/consonants/uppercase/lowercase characters in the file.
AIM:
To write a python program to define a function to write and read a text file and
display the number of vowels/consonants/uppercase/lowercase characters in the file.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
SAMPLE OUTPUT:
**********************************************************************************
3) Creating Python Program to define a function that reads the file first.txt and creates a
new file named second.txt, to contain only those words from the file first.txt which start
with a lowercase vowel (i.e. with 'a', 'e', 'i', 'o', 'u').
AIM
To write a Python Program to define a function that reads the file first.txt and
creates a new file named second.txt, to contain only those words from the file first.txt
which start with a lowercase vowel
(i.e. with 'a', 'e', 'i', 'o', 'u'
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
SAMPLE OUTPUT:
***********************************************************************
4) Creating Python Program to accept string/sentences from the user till the user enters
“END” to. Save the data in a text file and then display only those sentences which begin with
an uppercase alphabet.
AIM
To write a Python Program to accept string/sentences from the user till the user
enters “END” to. Save the data in a text file and then display only those sentences which begin
with an uppercase alphabet.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is
verified successfully.
SAMPLE OUTPUT:
***********************************************************************
5) Creating Python Program to define a function RevString to read a text file ‘Input.txt’ and
print the words starting with ‘o’, in reverse order. The rest of the content should display
normally.
AIM:
To write a Python Program to define a function RevString to read a text file
‘Input.txt’ and print the words starting with ‘o’, in reverse order. The rest of the content should
display normally.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
SAMPLE OUTPUT:
***********************************************************************
6) Creating python program to create and search records in binary file.
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.
SAMPLE OUPUT:
PYTHON PROGRAM EXECUTED OUTPUT:
***********************************************************************
7) Creating a python program to create and update/modify records in binary
file.
AIM:
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.
SAMPLE OUTPUT:
**********************************************************************************
8) Creating a menu based program to add,delete,and display the record of a hostel using a
list as stack data structure in Python.The record of Hostel contains the fields: Hostel
number,Total Students, and Total Rooms.
AIM:
To write a python program to add,delete,and display the record of a hostel using
a list as stack data structure in Python.The record of Hostel contains the fields: Hostel
number,Total Students, and Total Rooms.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is
verified successfully.
SAMPLE OUTPUT:
************************************************************************
9) A binary file“Book.dat” has structure[bookno,bookname,author,price]. Write a user
defined function CreateFile()toinputdataforarecordandaddtoBook.dat. Write a function
CountRec(Author)which accepts Authorname as parameter ,count and return number of
books by the given Author are stored in the binaryfile“Book.dat”.
AIM:
Result:
Thus, the above Python program has been executed and the output is
verified successfully.
SAMPLE OUTPUT:
************************************************************************
10) Creating a python program to create and search employee’s record in csv file.
AIM:
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is
verified successfully.
SAMPLE OUTPUT:
****************************************************************************
11) Write a program using python to get 5 players' names and their score.Write the
input in a csv file. Accept a player name using python.Read the csv file to display the
name and the score.If the player name is not found give an appropriate message.
AIM:
Creating a python program using python to get 5 players' names and their
score.Write the input in a csv file. Accept a player name using python.Read the csv file to
display the name and the score.If the player name is not found give an appropriate
message
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
********************************************************************************
12) Write Python Program to search record from “data.csv” according to the admission
number input from the user. The structure of the record saved in “data.csv” is
[Adm_no,Name,Class,Section,Marks].
AIM:
SOURCE CODE:
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
SAMPLE OUTPUT:
13) Create a Python Program
14) Create a python program to implement stack operations(list)
AIM:
To write a Python program to implement Stack using a list data-
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:
Result:
Thus, the above Python program has been executed and the output is
verified successfully.
SAMPLE OUTPUT:
************************************************************************
15) Creating a python program to implement stack operations(dictionary)
AIM:
To Write a program, with separate user-defined functions to perform
the followingoperations:
(i) 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.
(ii) 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.
(iii) 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:
************************************************************************
16) CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON
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 OUPUT:
********************************************************************************
17) Creating a python program to integrate mysql with python (inserting
AIM:
To write a Python Program to integrate MYSQL with Python
by inserting records to Emp table and display the records.
SOURCE CODE:
Result:
Thus, the above Python program has been executed and
the output is verified successfully.
SAMPLE OUTPUT:
********************************************************************************
18) CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON
AIM:
Result:
Thus, the above Python program has been executed and the output is
verified successfully.
SAMPLE OUTPUT:
19) CREATING A PYTHON PROGRAM TO INTEGRATE MYSQL WITH PYTHON
(UPDATING RECORDS)
AIM:
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.
SAMPLE OUTPUT:
20) SQL COMMANDS EXERCISE - 1
AIM:
Observe the following table Stock and Dealers and write queries given
below:
QUERIES:
c) To display the Itname, Dname and unitpr for all the stocks whose
quantity is more than 100.
AIM:
Observe the following tables SCHOOL and ADMIN and write queries given
below:
QUERIES:
Sol:
Output:
Sol:
Output:
22) SQL COMMANDS EXERCISE - 3
AIM:
Observe the following tables SCHOOL and Hostel and write queries given
below:
QUERIES:
OUTPUT:
Output:
23) SQL COMMANDS EXERCISE - 4
AIM:
Observe the following tables Customer and Orders and write queries
given below:
Output:
Output:
Output:
Output:
24) SQL COMMANDS EXERCISE - 5
AIM:
Observe the following tables Stationery and consumer and write queries
given below:
Queries:
25) SQL COMMANDS EXERCISE - 6
AIM:
Observe the following tables Vehicle and Travels and write queries given
below:
Queries: