When I first started playing around with lists and conditions in Python, I wanted to create something that felt more useful than just “print this” or “loop that”.
I wanted to write a small program that could take a few numbers from the user β then analyze them.
That’s how this little project was born.
The Idea
The concept was simple:
- Ask the user to input five numbers between 1 and 1000
- Store them in a list
- Then show a breakdown of what those numbers mean
I wanted to know:
- Which ones are even
- Which ones are above 500
- Which ones are above the average of the five
- What the min, max, and average are
And of course, all of that with proper formatting, useful messages, and no crashes if the user messes up.
The Logic
I started by using a for
loop to make sure I only ask for 5 numbers. Inside that, I placed a while True:
loop with a try-except
block to validate the input. If the user typed something that wasnβt a number, or if the number wasnβt in the 1β1000 range, they got a warning and could try again.
Once the list was filled, I used separate loops to:
- Collect even numbers into a new list
- Collect numbers greater than 500 into another
- Collect numbers above the calculated average into a third
Finally, I printed out a full report:
- The numbers entered
- The smallest and largest values
- The average, rounded to two decimals
- How many evens
- How many are over 500
- How many are above average (with the actual values)
What I Learned
This might look like a small script, but for me, it was a big lesson in:
- Input validation
- Data processing with lists
- Using loops and conditions effectively
- Calculating statistics like average, min, max
- Formatting output to be clear and readable
What’s Next?
Iβd love to turn this into a more flexible version β maybe let the user decide how many numbers they want to enter, or allow them to choose their own thresholds (e.g., βShow me all numbers above 250β).
Later on, I might also refactor the entire thing into functions, or even build a basic GUI to make it more user-friendly.
This script reminded me that you donβt need to build something huge to learn something valuable.
Sometimes, five numbers are all it takes.