Project Level 2: Intermediate
This project is designed for intermediate learners who know Python fundamentals and are practicing building complete programs.
Project Description
Create a program that reads a list of motivational quotes from a text file and selects one to display every Monday (or any day the user runs the program). It uses Python's date handling to check the current day and ensures you’re greeted with a new quote each time you run it.
Expected Output
A) Scenario 1: If Monday
The program checks what day it is. If it is Monday it displays the another text as shown above and picks a quote from the quotes.txt file.
B) Scenario 2: If not Monday
If it is not Monday, the program displays some other text as shown below:
Learning Benefits
File Handling: You will practice reading data from a file, a foundational skill for working with external resources such as databases, logs, or configuration files.
Randomization: You will practice using the
random
module to generate unpredictable results, which is common in applications like games, recommendations, and creative tools.String Processing: You will practice parsing and manipulating strings, such as slicing, stripping whitespace, and formatting text for better readability.
Control Flow: You will practice logical structures like
if-else
to make decisions based on user input, a core aspect of interactive programs.Output Formatting: You will practice creating user-friendly console outputs, a valuable skill for making your programs engaging and easy to use.
Prerequisites
Required Libraries: random, datetime
No need to install any library since random is a standard library.
Required Files: Download the text file in this link and place it in the same directory as your Python script.
IDE: You can use any IDE on your computer to code the project.
Danger Zone
Once you code the project, compare it with our solution below:
Here, today == "a" is not valid because datetime.now().strftime("%A") returns the full name of the day (e.g., "Monday", "Tuesday"), so "a" will never match any of these values. If you intend to check for Monday, you should compare today with "Monday".