Notebooks · Apr 27, 2025 · 2 min read

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 if statements 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:

  1. Ask the user to pick a fruit
  2. Compare the input against known options
  3. 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
  • else acts 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.


Notebook link: Coming Soon