Jan 26, 2026
# Chapter 2 — First Program, Printing, and the “Python Way”
Instead of starting with 20 rules, we start with a tiny program you understand.
Create `src/main.py` and write:
```python
name = "Meetcode Student"
print("Hello,", name)
```
Run it:
```bash
python src/main.py
```
## 2.1 Reading Errors Without Panic
When Python shows an error, it usually tells you:
- what happened (error type)
- where it happened (file + line)
- what line caused it
The goal is not “avoid errors”. The goal is “read errors fast”.
### A small mistake example
```python
print("Hello"
```
You will get a message about missing `)` and it points to the line.
## 2.2 Print Is Not Only for Beginners
`print()` is a simple debugging tool. Even pros use it to quickly confirm:
- “Did this function run?”
- “What value is inside this variable?”
- “Which branch did the program take?”
Later you will learn logging, but print is a good start.
## 2.3 The “Small Debug Loop” (A Habit That Makes You Fast)
When something breaks, do this loop:
```text
1) Reproduce the bug (same input, same steps)
2) Reduce the problem (smallest code that still fails)
3) Inspect values (print/log)
4) Fix one thing
5) Run again
```
### A tiny example: checking your assumptions
```python
items = ["10", "20", "30"]
total = 0
for x in items:
total = total + int(x)
print(total)
```
---