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.
[Link].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.
[Link].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.
[Link].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.
[Link].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("[Link]","rb+")
print([Link]())
[Link](4,0)
print([Link](5))
[Link](10,1)
print([Link]())
print([Link](10))
navigation()
Sample output:
Content in [Link]
A computer network is a set of computers sharing resources located on or provided by network nodes
======== RESTART: C:\Users\USER\Desktop\[Link] ========
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.