Grade - 12 - Lab - Exercise Python
Grade - 12 - Lab - Exercise Python
Aim:
To write a python program to read a text file line by line and display each word separated by a #.
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.
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.
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.
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.
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.
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.
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.
Aim:
To write a python program to know the cursor position and print the text according to below-
given specifications:
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
b 'mpute'
19
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.