Skip to content

Pushpendra202001/python-module-5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-module-5

========================================ASSIGNMENT 4:=====================================================

====================Module 5: Files, Exceptions, and Errors in Python=================================

Task 1: Read a File and Handle Errors Problem Statement: Write a Python program that:

  1. Opens and reads a text file named sample.txt.
  2. Prints its content line by line.
  3. Handles errors gracefully if the file does not exist. file is readop.py Expected Output: Reading file content: Line 1: This is a sample text file. Line 2: It contains multiple file.

===========================Task 2: Write and Append Data to a File===============================

Problem Statement: Write a Python program that:

  1. Takes user input and writes it to a file named output.txt.
  2. Appends additional data to the same file.
  3. Reads and displays the final content of the file.

Expected Output: For example, if the user enters 25, the output should be:-

Enter text to write to the file:Hello, Python! Data successfully written to output.txt. Enter additional text to append:Learning file handling in python. Data successfully append Hello, Python! Learning file handling in python.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages