Learn Python by Building a Trip Planner · Chapter 0

How we learn, and getting set up

Before the first line of the app: how this series works, your first program, your first red error, and your own key for Spark, the study buddy beside every lesson.

One sitting~4 min read, ~20 min practice
4 ideaseach: a short read, then practice
6 exercisesAI shows · AI helps · no AI
Nothing to installreal Python, in your browser
Nothing is assumedNever written a line of code? You are exactly the person this series is written for.
Goes with the videoEpisode 0, "How does this series work?". The video shows it; this page teaches it again, slowly, with practice.
Progress is optionalSign in (top right) and your journey follows you across devices. Everything works without an account too.

How we learn here

So, how will you learn Python here? Let's try to understand.

We learn Python by building one app: Our Trip Planner. Four friends plan a weekend trip from Bengaluru. By the end, the app asks where we are going, takes our expenses, splits the bill, checks the budget and finds the weather there. You will have built every line of it, and most of it by yourself.

But the app is not the goal. Learning Python is the goal. The app is the reason we learn each thing, at the moment we need it.

Say you moved to a hostel and had to cook for yourself. Nobody gave you a cookery syllabus. You wanted tea, so you learned tea. Then rice, because you were hungry. Each dish came when you needed it, and you never forgot it.

Every chapter works the same way:

How every chapter works
a feature we want → we try it with what we know → we get stuck → we discover a new tool → other ways, and our pick → the feature works

The point where what you know runs out is what we call a challenge. Programmers also call it a bottleneck. Every challenge is the start of the next lesson.

We are learning Python in the AI era. So you use AI from the very first day. But how you use it changes, inside every chapter:

  1. AI shows. It writes the code; you read it, run it, and break it.
  2. AI helps. You write; you ask only when you are stuck.
  3. No AI. The last exercises are yours alone.

That last step matters most. If you cannot write it without AI, you cannot check what AI writes for you.

Each chapter lives in two places. The video teaches each idea while we build the Trip Planner. This page teaches the same ideas again, with many practice exercises. And here you build a second app, by yourself: a Weekly Grocery Run, one step every chapter. Chapters 1 to 7 run right here, in your browser. From chapter 8, we move to your own Windows computer.

Your first run

Enough talk. Let's run something.

The box below holds a program: one line of Python. Press ▶ Run. The dark panel under it is the output: what the program shows you.

Now change the word inside the quotes to your own name, and press Run again. Change, run, look. That small loop is most of programming.

Made a mess? ↻ Reset brings back the starting code.

This is real Python, rebuilt to run inside your browser. Nothing to install. Ideally, you would download Python from python.org; for chapters 1 to 7, it is already here for you.

When it goes red

So what happens when something is wrong? Let's break it on purpose.

This program is missing its closing bracket. Run it.

Red text. That is an error message. It is not the computer breaking. It is Python telling you where it got stuck, and why.

Read it from the bottom. The last line says what went wrong: '(' was never closed. Just above it, the line number says where to look.

Want the full story of what happens when you press Run, and why one missing bracket stops the whole program? Read What is a Python program?

Careful here

An error is not a failure. Every programmer sees dozens a day. The skill is reading them, and you will practise it in every chapter.

Your own key, and Spark

Every lesson in this series has Spark, our study buddy: the round ✦ star button at the bottom right of this page. Spark explains things right beside the lesson, using what is on the page.

Spark thinks with Google's Gemini, using your own key. You get the key once, from Google AI Studio, with your Google account, and use it along the way, for your learning.

Getting your key takes about five minutes. Follow How do I get my own Gemini API key, and connect Spark?, then come back here.

Then say hello. Press the ✦ Spark button and ask: "What does the Run button do?"

Your key is like a password
Give it to Spark, and to no one else. It stays only in this browser. On a shared computer, open Spark's ⚙ settings, empty the key box and press Save settings, before you leave.

Stuck on the key? Use Gemini chat at gemini.google.com for now, and come back to Spark later. What a key really is, and why it stays a secret, is a whole chapter later on. For now, it is simply yours.

Practice

Six short exercises. The first two let AI show you; the middle two, AI only helps; the last two are yours alone.

0 · P1 · AI showsAsk Spark for a program

Ask Spark for a one-line program that says hello. Paste its line here, and run it.

0 · P2 · AI showsAsk what an error is

Highlight error message above and ask Spark about it. Write its answer in your own words.

0 · P3 · AI helpsThree lines

Print these three lines, in this order. Ask Spark only if you are stuck. Then press ✓ Check.

Hello I am learning Python by building an app
Show solution
print("Hello")
print("I am learning Python")
print("by building an app")

One print() for each line, top to bottom.

0 · P4 · AI helpsYour trip card, by hand

Print a tiny trip card: where you would go, and with whom. Two lines, your own words.

0 · P5 · No AIBreak it, read it

Delete the closing quote, and run it. Write what the error's last line says, in your words.

0 · P6 · No AIFix it

This program is broken in one place. Find it, fix it, and press ✓ Check.

Show solution
print("Our Trip Planner")

The closing quote was missing, so Python could not tell where the text ends.

Check yourself

Four questions. A wrong answer here is worth more than a right one: read the explanation either way.

Glossary

Every word from today that you will need again.

References

Where to read more on today's ground.

  1. Google — Google AI Studio: API keys. Where you create your own Gemini API key, with your Google account. aistudio.google.com
  2. Google — Gemini API: pricing and rate limits. What your key can use, and its limits; they change, so check here. ai.google.dev
  3. Pyodide — Pyodide 0.26.4. The real Python (3.12) that runs inside your browser. pyodide.org
  4. The Python Tutorial — §3 An Informal Introduction to Python. The official first steps, in the language's own voice. docs.python.org