COMP-1034: Files and CSV Practice Problems 1. Write a Python script to read a text file and display its content. 2. Write a Python script to write a text file with some content. 3. Write a Python script to append text to an existing text file.
COMP-1034: Files and CSV Practice Problems
1. Write a Python script to read a text file and display its content.
2. Write a Python script to write a text file with some content.
3. Write a Python script to append text to an existing text file.
4. Write a Python script to copy the contents of one file into another file.
5. Write a Python script to count the number of lines in a text file.
6. Write a Python script to read a text file and find the longest word.
7. Write a Python script to read a text file and find the shortest word.
8. Write a Python script to read a text file and replace a specific word with another word.
9. Write a Python script to read a CSV file and display the data.
10. Write a Python script to write a CSV file with some data.
11. Write a Python script to append data to an existing CSV file.
12. Write a Python script to count the number of rows in a CSV file.
13. Write a Python script to count the number of data rows in a CSV file. This means to exclude
the header row.
14. Write a Python script to count the number of columns in a CSV file. The columns are
identified on the first row.
15. Write a Python script to read a CSV file and display the first 5 rows not including the column
headers.
16. Write a Python script to read a CSV file and display the last 5 rows.
17. Create a CSV file in Jupyter that has 5 stocks: symbol, company name and quantity of
shares. Write a Python script to read the CSV file and calculate the sum of shares.
18. Write a Python script to read the CSV file in #17 and calculate the average number of
shares.
19. Write a Python script to read a CSV file in #17 and find the stock with the maximum number
of shares.
Step by step
Solved in 3 steps