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

Python Assignment 4

This document is an assignment for a Python Programming course, requiring students to answer five questions related to file handling in Python. Questions include explaining file reading methods, creating and manipulating text files, and understanding the seek() function. Students must submit handwritten answers with proper explanations and code examples by June 11, 2025.
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)
9 views1 page

Python Assignment 4

This document is an assignment for a Python Programming course, requiring students to answer five questions related to file handling in Python. Questions include explaining file reading methods, creating and manipulating text files, and understanding the seek() function. Students must submit handwritten answers with proper explanations and code examples by June 11, 2025.
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
You are on page 1/ 1

ASSIGNMENT NO.

– 4
COURSE: - PYTHON PROGRAMMING
COURSE CODE: - BCC402
PROGRAME NAME: - B.Tech (EE)
SEMESTER: - Fourth
YEAR: - Second
DATE OF SUBMISSION:11/06/2025

Total Questions: 5
Instructions: Attempt all questions. Submit your handwritten with proper
explanations and Python code where applicable.

QUESTION NO:1-Explain the difference between the following file reading methods in
Python with suitable examples:
(a) read()
(b) readline()
(c) readlines()
QUESTION NO:2- Write a Python program to:
• Create a text file named sample.txt
• Write at least five lines into the file using write() or writelines()
• Read and display the contents of the file

QUESTION NO:3- What is the use of the seek() function in Python? Write a Python program that
demonstrates how the file pointer can be moved using seek().

QUESTION NO:4- Write a Python program that:


• Opens an existing file
• Reads and prints only the second line using file functions

QUESTION NO:5- Describe the difference between write() and writelines() functions in Python.
Give one code example for each to demonstrate their usage.

You might also like