0% found this document useful (0 votes)
5 views1 page

Python Assignment 4 Long Answers

The document is an assignment for a Python programming course at IMS Engineering College, focusing on file handling. It covers the open() function modes, various file reading and writing functions, the concept of a file pointer, and includes a sample Python program demonstrating file creation, writing, and reading. Key functions discussed include read(), readline(), write(), and writelines().

Uploaded by

dalipnain621
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Python Assignment 4 Long Answers

The document is an assignment for a Python programming course at IMS Engineering College, focusing on file handling. It covers the open() function modes, various file reading and writing functions, the concept of a file pointer, and includes a sample Python program demonstrating file creation, writing, and reading. Key functions discussed include read(), readline(), write(), and writelines().

Uploaded by

dalipnain621
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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]()

You might also like