IMS Engineering College, Ghaziabad
Department of IT/BT
Python Programming – Assignment 4
Course Code: BCC402
Q1. Explain file handling in Python. Describe different modes used in the open() function.
File handling in Python refers to the process of working with files such as creating a file, opening a file, readi
The open() function supports different modes. The 'r' mode is used to read an existing file. The 'w' mode is u
Q2. Explain read(), readline() and readlines() functions.
The read() function reads the complete content of a file at once and returns it as a string. The readline() func
Q3. Explain write() and writelines() functions.
The write() function is used to write a single string into a file. It does not add a new line automatically. The w
Q4. What is a file pointer? Explain seek() function.
A file pointer is a cursor that indicates the current position in a file where the next read or write operation will
Q5. Write a Python program to create a file, write data and read it.
Program:
file = open('[Link]', 'w')
[Link]('This is Assignment 4 of Python File Handling.')
[Link]()
file = open('[Link]', 'r')
print([Link]())
[Link]()