Q2.Program to find file pointer position after writing data in file.f=open("j.txt","w+") f.write("my name is xyz") f.seek(11) print(f.read()) f.close() Output >>> ==================== RESTART: C:/Users/Dell/Desktop/dd.py ==================== xyz
Q3.Program to read data from the filef=open("j.txt","w+") f.write("my name is xyz") n=f.tell() print(n) f.close() output >>> ==================== RESTART: C:/Users/Dell/Desktop/dd.py ==================== 14
Q4.Program to read only first 5 byte of string "hello everyone"f=open("p.txt","r+") f.write("my name is abc") print(f.read()) f.close() output >>> ==================== RESTART: C:/Users/Dell/Desktop/gj.py ==================== my name is abc
Q5 Program to read one row from file.f=open("u.txt","r+") f.write("hello everyone") print(f.read(5)) f.close() Output >>> ==================== RESTART: C:/Users/Dell/Desktop/fg.py ==================== hello
f=open("t.txt","r+") f.write("hello everyone") print(f.readline()) f.close() output >>> ==================== RESTART: C:/Users/Dell/Desktop/sh.py ==================== hello everyone >>>
0 Comments