Exercise 5
Exercise 5
1. Write a program in Python to count and display the total number of words in a text
file.
2. Write a program in Python to read lines from a text file "notes.txt". Your function
should find and display the occurrence of the word "the".
3. Write a program
a. To print the names of all the items in the current working directory using
os.listdir().
b. Create a new directory within the current working directory only after
checking if the directory already exists or not.
c. To rename the file “oldfile.txt” to “newfile.txt” within the new directory.
d. To remove the file “newfile.txt”.
e. To remove the new directory that was created on 5.b.
4. Create text file containing at least 100 floating point numbers and name it
‘example3.txt’. Now, write a program to access the file and compute the average of
all the numbers within the text file.