0% found this document useful (0 votes)
49 views52 pages

Final Cs Lab Manual

Uploaded by

asm.adityakumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views52 pages

Final Cs Lab Manual

Uploaded by

asm.adityakumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

1) Creating Python Program to define a function to create and read a text file

"Story.txt" line by line and display each word separated by '#'.

AIM:

To write a python program to define a function to create and 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:
Python Executed Program output:

Sample.txt

Python Executed Program Output:

*********************************************************************************
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:

To create 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”.
SOURCE CODE:

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:

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.
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:

To create a 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].

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-

structure, to perform the following operations:

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:
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

(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 OUPUT:

********************************************************************************
17) Creating a python program to integrate mysql with python (inserting

records and displaying records)

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

(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:
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:

a) To display details of all items in the stock table in descending order of


Stkdate.
b) To display the details of those items whose Dcode (Dealer Code) is 102
and Qty (Quantity) is more than 50 from the table stock.

c) To display the Itname, Dname and unitpr for all the stocks whose
quantity is more than 100.

d) To display the stock details in the descending order of unitpr


21) SQL COMMANDS EXERCISE - 2

AIM:

Observe the following tables SCHOOL and ADMIN and write queries given
below:

QUERIES:

(i)Write a Query to display the records of Teachers whose periods are


more than 25.

Sol:

SELECT *FROM SCHOOL WHERE PERIODS>25;


OutPut:

ii) Write a Query to display DESIGNATION without duplicate entries


from the table ADMIN

Sol: SELECT DISTINCT DESIGNATION FROM ADMIN;

Output:

iii) Write a Query to display TEACHER NAME, CODE and corresponding


DESIGNATION from tables SCHOOL and ADMIN of Male teachers.

Sol:

select Teacher,school.code,designation from school,admin

-> where gender="Male" and school.code=admin.code

Output:
22) SQL COMMANDS EXERCISE - 3

AIM:

Observe the following tables SCHOOL and Hostel and write queries given
below:
QUERIES:

(i) Display the records from Student whose combination is PCMC.

Sol: SELECT *FROM STUDENT WHERECOMBINATION="PCMC";

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:

You might also like