Add lesson 1: Your first program
3 changed files with 29 additions and 0 deletions
lessons/01-your-first-program/README.md ADDED
| @@ -0,0 +1,19 @@ | ||
| 1 | +# Lesson 1: Your first program | |
| 2 | + | |
| 3 | +Your first program comes up in almost every real Python project. We start with the why, then write code together. | |
| 4 | + | |
| 5 | +Full lesson: [https://glibcode.net/courses/python-basics/lessons/1](https://glibcode.net/courses/python-basics/lessons/1) | |
| 6 | + | |
| 7 | +## Files | |
| 8 | + | |
| 9 | +- `hello.py`: prints a greeting and asks for your name | |
| 10 | + | |
| 11 | +## Run it | |
| 12 | + | |
| 13 | +```sh | |
| 14 | +python3 hello.py | |
| 15 | +``` | |
| 16 | + | |
| 17 | +## Exercises | |
| 18 | + | |
| 19 | +See [exercises.md](exercises.md). Ask in the forum once you've tried. | |
lessons/01-your-first-program/exercises.md ADDED
| @@ -0,0 +1,5 @@ | ||
| 1 | +# Exercises: lesson 1 | |
| 2 | + | |
| 3 | +1. Run `hello.py` and change one value. Write down what you expect, then run it again and compare. | |
| 4 | +2. Add a check that prints a warning when a result looks wrong (negative, empty, too big). | |
| 5 | +3. Find one thing in `hello.py` you could name better and rename it everywhere. | |
lessons/01-your-first-program/hello.py ADDED
| @@ -0,0 +1,5 @@ | ||
| 1 | +# Lesson 1: your first program | |
| 2 | +print("Hello, world!") | |
| 3 | + | |
| 4 | +name = input("What is your name? ") | |
| 5 | +print(f"Hello, {name}! Welcome to Python.") | |