Handling TXT File

Qus. 1 : <p>What will be the output of the following code?</p><pre>f=open("demo.txt","r")<br>print(f.tell())</pre>

  1. 1
  2. 2
  3. -1
  4. 0
Qus. 2 : <p>What will be the output of the following code ?</p><pre>f=open("demo.txt","w+")<br>f.write("Welcome to python")<br>f.seek(5)<br>a=f.read(5)<br>print(a)</pre>

  1. Welco
  2. me to
  3. Welcome to Python
  4. e to
Qus. 3 : f.read(5) will read________from a file (file object 'f')

  1. 5 characters
  2. 5 words
  3. 5 lines
  4. None of the above
Qus. 4 : Which statement will move file pointer 10 bytes backward from current position.

  1. f.seek(-10, 0)
  2. f.seek(10,0)
  3. f.seek(-10, 1)
  4. None of the above
Qus. 5 : Work of tell() method in file processing is

  1. Tells you the current position within the file.
  2. Tells the size of file you read
  3. Tells the start position of the file.
  4. Tells the end position of the file.

Programs

python program to read the full content of specified txt file

View Solution


python program to accept file name and data from user and write data on file

View Solution


python program to count the number of lines in the file

View Solution


python program to display the size of a file in byte

View Solution


python program to display all the records in a file along with line number

View Solution


python program to display only last line of a text file

View Solution


python program that reads a text file and creates another file that is identical except that every sequence of consecutive blank spaces is replaced by single space

View Solution


python program to create a function that would read contents from the sports.dat and creates a file named Atheletic.dat

View Solution


python program to read csv file content line by line

View Solution


Write Python code to display sentence starting with given character from abc.txt file

View Solution


Python code to display digits from abc.txt file

View Solution


python program to copy the one contents to another

View Solution


python program to copy the all word which start with constant in another file

View Solution


python program to add delete and display all record of binary file

View Solution


python program to read data from csv file

View Solution


Python program to write data on csv file

View Solution


python program to write first n prime number in text file

View Solution


python program to marge the content of target file into source file

View Solution


python program to read txt file data from specified index to specified length

View Solution


python program to delete the specified file from computer

View Solution


Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad