Python Assignment 4
Python Assignment 4
– 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:5- Describe the difference between write() and writelines() functions in Python.
Give one code example for each to demonstrate their usage.