Unit 1 · Lesson 1

Think, Code, Run

Write clear Python, classify errors, and debug with confidence.

🤖 Algorithm Discovery

Arrange a short sequence and watch the robot follow exactly what you provide.

Command Bank

Add steps to your algorithm.

Step-by-Step Sequence0/8

Algorithm is empty.
Select commands to start.

🧭 What Is an Algorithm?

A precise, step-by-step procedure for solving a specific task.

1

Step-by-step

Each action is listed in clear order.
2

Finite

The procedure always reaches an end.
3

Precise

No guessing — every step is unambiguous.
6:00 AM
01
Alarm Rings
02
Snooze?
03
Get Out of Bed
04
Start Your Day
05

🧩 From a Plan to Code

An algorithm is the plan. A program expresses the plan in instructions Python can run.

📝 → 💻

Clear steps become code

Python follows the instructions we write. Their order, spelling, and symbols all matter.

⚠️ When Things Go Wrong

Mistakes are normal. The first useful question is: what kind of error is this?

🐛 The Three Error Families

The symptoms tell us where to begin looking.

🧱

Syntax Error

Breaks Python's grammar, so the program cannot start normally.

🎯

Logic Error

Runs without crashing, but produces the wrong result.

💥

Runtime Error

The program starts, then fails during execution.

🔍 Error Detective (1/3)

Classify the problem before trying to fix it.

📝

Question

You type an email address without the @ symbol. The form immediately reports an invalid format and refuses to continue.

Which error family does this describe?

🔍 Error Detective (2/3)

Classify the problem before trying to fix it.

📝

Question

A GPS app runs normally and announces that you have arrived, but it guided you to the wrong street.

Which error family does this describe?

🔍 Error Detective (3/3)

Classify the problem before trying to fix it.

📝

Question

A mobile game opens successfully, but it suddenly closes during the third level.

Which error family does this describe?

💬 String Literals

Quotes tell Python that the characters inside are text data.

💬

"Hello, Python!"

The quotes mark the boundaries. The text between them is the string literal.

Text, Not Instructions

Python displays the characters inside instead of trying to execute them.

Matching Quotes

A string must begin and end with matching quote characters.

👀 Read Your First Program

Predict what Python will display before the program runs.

lesson01_first.py

▶️ Run and Check

Python executes each instruction from top to bottom.

lesson01_first.py
Console Output
Hello, Python! My name is Alex. 2026

🖥️ Output Mechanics

print() displays its arguments and then moves to a new line by default.

Function Name

print tells Python to display a value.

Argument

The parentheses hold the value passed to print.

New Line

After each print() call, Python moves to the next line by default.

output_mechanics.py
Console Output
Python is clear Next line

🔍 Output Check

What exactly appears in the output? Include spaces and line breaks.

output_check.py

✨ Escape Sequences

A backslash gives special meaning to the character that follows it.

escape_sequences.py
Console Output
Line 1 Line 2 She said "Hi!" Folder: C:\Python
\n

New Line

Moves the output to the next line.

\"

Double Quote

Prints a quote inside text.

\\

Backslash

Prints one backslash.

🔍 Escape Check

What exactly is printed?

escape_check.py

🔎 Find the Broken Detail

Classify the error, then notice the two places a comment can appear.

broken_greeting.py

For Humans

A comment explains purpose, choices, or reminders to the reader.

Starts with #

Everything after # on that line is treated as a comment.

Not Output

Python ignores the comment when it runs the program.

🛠️ Use the Debugging Loop

An error message is evidence that helps you choose the next change.

1

Read

Start with the final line of the error message and note the line number.
2

Compare

Compare the broken line with a working Python pattern.
3

Change One Thing

Fix the smallest likely cause instead of rewriting everything.
4

Run Again

Use the new result as evidence that the change worked.

✅ Fixed and Running

The closing quote completes the string, so Python can run both instructions.

fixed_greeting.py
Console Output
Hello, Python! I am ready to code.

📝 Homework

Complete it on time and submit it before the deadline.

🔖 Summary

Key takeaways from this lesson.

Classify

Errors can be syntax, logic, or runtime errors.

Output

Strings, print(), and escape sequences control displayed text.

Debug

Read, compare, change one thing, and run again.

🧠 Task 1: Classify the Error

Use the symptom, not a guess, to choose the error family.

Your Goal

1. Write Syntax, Logic, or Runtime for each situation.

Situations
A. A missing quote prevents a program from starting.
B. A calculator runs but adds instead of multiplying.
C. A game closes only when a level loads.

👀 Task 2: Predict the Output

Write the exact output before running the code.

Your Goal

1. Predict every space and line break in the output.

2. Run the code and compare the result with your prediction.

Example Code

🖥️ Task 3: Match the Output

Use string literals and escape sequences to reproduce the target exactly.

Your Goal

1. Write a Python program that produces the target output exactly.

2. Use at least one \n, one \", and one \\.

Target Output
PYTHON PROFILE
Name: "Ada"
Path: C:\Python
Ready!
Go!

💬 Task 4: Add Comments

Document the program without changing what it prints.

Your Goal

1. Add one full-line comment describing the program.

2. Add one comment after a code line.

3. Run the program and confirm that the output is unchanged.

Example Code

🛠️ Task 5: Debug and Improve

Repair the program, then extend it without introducing new syntax errors.

Your Goal

1. Classify the error that prevents this program from running.

2. Repair the smallest broken detail and run again.

3. Add two profile lines, including one comment after a code line.

4. Check every space, quote, and line break in the final output.

Example Code
01 / 26