Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Python File Handling

Objective

Demonstrate understanding of Python file handling by completing the following tasks.

Tasks:

  1. File Creation:

    • Create a Python script (file_handling_assignment.py) that does the following:
    • Creates a new text file named "my_file.txt" in write mode ('w').
    • Write at least three lines of text to the file, including a mix of strings and numbers.
  2. File Reading and Display:

    • Enhance your script to read the contents of "my_file.txt" and display them on the console.
  3. File Appending:

    • Modify the script to open "my_file.txt" in append mode ('a').
    • Append three additional lines of text to the existing content.
  4. Error Handling:

    • Implement error handling using try, except, and finally blocks to manage potential file-related exceptions (e.g., FileNotFoundError, PermissionError).

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages