Fruit Picker
🍓 Introduction: Making Choices with Code
Once you know how to calculate and sort data, the next step is learning how to make decisions.
This notebook introduces a Fruit Picker — a simple exercise that demonstrates how Python uses conditional logic to decide what happens next based on user input.
It’s where code starts to feel a little more alive.
🎯 Purpose: Learning Conditional Logic
The goal of this notebook is to help beginners understand:
- How
ifstatements work in Python - How user input can influence program flow
- How programs make decisions based on conditions
- Why control flow is essential in real applications
Almost every program you use relies on this logic.
🧠 How It Works: Decision-Based Flow
At a high level, the notebook follows this process:
- Ask the user to pick a fruit
- Compare the input against known options
- Respond differently depending on the choice
This introduces the idea that not all code runs all the time.
🧩 The Technical Part: If, Elif, Else
A simplified version of the core logic looks like this:
fruit = input("Pick a fruit: ")
if fruit == "apple":
print("You picked an apple 🍎")
elif fruit == "banana":
print("You picked a banana 🍌")
else:
print("Fruit not recognised")
🔍 What’s Happening Here?
- The program evaluates conditions top to bottom
- Only the first matching condition runs
elseacts as a fallback for unexpected input- User input directly affects program behaviour
This is a foundational pattern used everywhere — from forms to APIs.
💡 Key Takeaways: Thinking Like a Program
This notebook teaches several important ideas:
- 🔀 Programs don’t guess — they evaluate conditions
- 🧭 Control flow determines outcomes
- 🧠 Clear conditions lead to predictable behaviour
- 🛠 Handling unexpected input is part of good design
Once this clicks, programming starts to feel logical instead of mysterious.
🏁 Conclusion: From Data to Decisions
The Fruit Picker marks an important shift:
Your program is no longer just processing data — it’s responding to choices.
With conditionals mastered, you’re ready to explore:
- Loops
- Functions
- Validation
- More complex user interactions
Every smart program starts with a simple if.
🔗 Link to Notebook
Notebook link: Coming Soon