Question: Tasks: Reading from a .txt file: Create a text file named sample.txt and write some sample text into it. Write a Python program to read

  • Tasks:
    1. Reading from a .txt file:
      1. Create a text file named "sample.txt" and write some sample text into it.
      2. Write a Python program to read the contents of "sample.txt" and display them on the console.
    2. Writing to a .txt file:
      1. Create an empty text file named "output.txt".
      2. Write a Python program that takes user input (text) and appends it to "output.txt". Repeat this process five times.
    3. Reading from a .csv file:
      1. Create a CSV file named "data.csv" with the following headers: "Name", "Age", "Gender".
      2. Add at least five rows of data to the CSV file.
      3. Write a Python program to read "data.csv" and display its contents row by row.
    4. Writing to a .csv file:
      1. Write a Python program that prompts the user to enter information for a new person (name, age, gender).
      2. Append this information to the existing "data.csv" file.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!