In this assignment, you will embark on an adventure to explore the vast collection of literary works available at Project Gutenberg. You will learn how to open and read contents from external files in Python while uncovering interesting facts about famous books and authors. Get ready for a journey through words!
-
Familiarize yourself with Project Gutenberg, a digital library that offers over 60,000 free eBooks.
-
Choose any book of your choice from Project Gutenberg. Consider selecting a classic novel or a renowned piece of literature.
-
Write a Python program that accomplishes the following tasks:
- Open the chosen book's text file (available in plain text format on Project Gutenberg).
- Read and display the book's title, author, and publication date.
- Count the total number of paragraphs in the book and display the result.
- Prompt the user to enter a word or phrase.
- Search the book for occurrences of the entered word or phrase.
- Display the number of times the word or phrase appears in the book.
-
Test your program with different books and search terms to ensure its functionality and correctness.
-
Document your code using comments to explain its logic and functionality clearly.
-
Add appropriate error handling to account for scenarios such as file not found or errors during file reading.
Note: Make sure to download the text file of the chosen book from Project Gutenberg and save it in the same directory as your Python program file.
Bonus Challenges (Optional):
- Implement a feature to calculate the average word length in the book.
- Extend the search functionality to allow searching for multiple words or phrases and display the occurrences of each.
- Create a graphical user interface (GUI) for your program, allowing users to select a book and search for words using buttons and text fields.
- Submit your Python program file (e.g.,
project_gutenberg_explorer.py) along with the chosen book's text file. - Include a document (e.g.,
README.txtorREADME.md) explaining how to run your program and any additional features you implemented.
Remember to have fun exploring the treasures of Project Gutenberg while mastering the art of opening and reading contents from external files in Python!