0% found this document useful (0 votes)
10 views

Grade - 12 - Lab - Exercise Python

Uploaded by

Reethi Saravanan
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)
10 views

Grade - 12 - Lab - Exercise Python

Uploaded by

Reethi Saravanan
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/ 10

Grade 12 Lab Tasks

Ex. no.1. Word separation in text file

Aim:

To write a python program to read a text file line by line and display each word separated by a #.

Algorithm: <<<to be written by the students>>>

Result:

Thus, the Python program to read a text file line by line and display each word separated by a # is
written, executed successfully and the output is verified.
Ex. no.2. Display Characters in text file

Aim: To write a python program to read a text file and display the number of
vowels/consonants/uppercase/lowercase characters in the file.

Algorithm: <<<to be written by the students>>>


Result:
Thus, the Python program to read a text file and display the number of
vowels/consonants/uppercase/lowercase characters in the file is written, executed successfully and
the output is verified.

Ex. no.3. Creating new file from source file

Aim:

To write a python program to remove all the lines that contain the character 'a' in a file and write it to
another file.

Algorithm: <<<to be written by the students>>>


Result:

Thus, the Python program to remove all the lines that contain the character 'a' in a file and write it to
another file is written, executed successfully and the output is verified.

Ex.No.4. Searching data in a binary file

Aim:

To write a python program to create a binary file with name and roll number. Search for a given roll
number and display the name, if not found display appropriate message.

Algorithm: <<<to be written by the students>>>


Result:

Thus, the Python program to create a binary file with name and roll number and to search for a given
roll number and display the name, if not found display appropriate message is written, executed
successfully and the output is verified.
Ex.No.5. Updating Data in binary file

Aim:

To write a python program to create a binary file with roll number, name and marks. Input a roll number
and update the marks.

Algorithm: <<<to be written by the students>>>


Result:

Thus, the Python program to create a binary file with roll number, name and marks and input a roll
number to update the marks is written, executed successfully and the output is verified.
Ex.no.6. Searching data in CSV file

Aim:

To write a python program to create a CSV file by entering user-id and password, read and search the
password for given user- id.

Algorithm: <<<to be written by the students>>>


write( )
search( )
Sample output:

<<<to be written by the students>>>

Result:

Thus, the Python program to create a CSV file by entering user-id and password, read and search the
password for given user- id is written, executed successfully and the output is verified.

Ex.NO.7. Navigations of cursor position in text file

Aim:

To write a python program to know the cursor position and print the text according to below-
given specifications:

1. Print the initial position

2. Move the cursor to 4th position

3. Display next 5 characters

4. Move the cursor to the next 10 characters

5. Print the current cursor position

6. Print next 10 characters from the current cursor position


Algorithm: <<<to be written by the students>>>

Source Code:
def navigation( ):

f=open("merge.txt","rb+")
print(f.tell())

f.seek(4,0)

print(f.read(5))

f.seek(10,1)

print(f.tell())

print(f.read(10))

navigation()

Sample output:

Content in merge.txt

A computer network is a set of computers sharing resources located on or provided by network nodes

======== RESTART: C:\Users\USER\Desktop\sample.py ========

b 'mpute'

19

b 'is a set o'

Result:

Thus, the Python program to know the cursor position and print the text according to given
specification is written, executed successfully and the output is verified.

You might also like