The Program reads the file sample.txt present on the same directory. If the file doesn't exist, it raises the appropriate error, otherwise, it prints the line by numbers
Execution command:
python "Task 1.py"Output:
Line 1: This is a sample text file.
Line 2: It contains multiple lines.
The Program accepts a line to write in the file and anoter line to append it and then prints the file data.
Execution command:
python "Task 2.py"Output:
Enter text to write to the file: Python TuteDude Assignment
Data successfully written to output.txt.
Enter additional text to append: Assignment no. 4
Data successfully appended.
Final content of the output.txt:
Python TuteDude Assignment
Assignment no. 4