Week 1: Set up Python and run your first programs¶
~9 min
This week's goal¶
By the end of this week, Python 3 runs on your computer, you can run a script file from the terminal, and you can write a program that asks for input and prints a sentence. You also learn what a program is, which is the first lesson of the Python course.
The main text is Part 1 of the Python course, lessons 1 to 3. Do not read ahead. Lessons 4 to 6 belong to week 2.
Day-by-day (about 1.5-2 hours per day)¶
Day 1. Read what a program is. It takes about 10 minutes. Then install Python 3 from the official downloads page. Follow the install steps in installing and running Python. If the installer asks, add Python to your PATH. Open a terminal and check the version with python3 --version. On Windows, try py --version if python3 is not found. Write the version number in a notes file. You will need it when an error message does not match the lesson.
Day 2. Finish lesson 2. Start the interactive prompt, type print("hello"), and see what it does. Exit the prompt, then create a file called hello.py with one line, print("hello"). Run it with python3 hello.py. Notice the difference: the prompt runs each line as you type it, and a file runs from top to bottom. Change the text inside the quotes and run the file again.
Day 3. Make a folder for the course, such as python-course/week-01, and keep your files there. Move into it with cd and list its contents with ls (on Windows, dir). If you are not sure about these commands, read the terminal and shell page for a short start. Then read lesson 3, showing output and reading input. Write a file called about.py that uses input to ask for your name.
Day 4. Extend about.py so that it also asks for your age and prints one sentence with both values, such as Ana is 19 years old. Do not worry about types yet. Run the file three times with different answers. Each time, the output should match the answers you typed.
Day 5. Write a second program, greet.py, that asks for a name twice and prints a greeting for each. Then try one change on purpose. Remove a closing quote, run the file, and read the error message. Compare it with the reading errors lesson in week 2. Do not fix it yet. Just note the line number and the error type.
Day 6. Close your notes and rebuild about.py from memory. Then compare it with your first version. Write three sentences in your notes about what happened when you ran a file. Keep this short. The goal is to see that a program is a list of instructions that run in order, and that input gives you text back.
Day 7 is a rest day.
Deliverable¶
A folder with two files. hello.py prints a line of text. about.py asks for a name and an age and prints one sentence with both. Both run from the terminal with python3, and your notes file records the Python version you installed.
Check yourself¶
- What is a program, in one sentence?
- What is the difference between typing a line into the interactive prompt and saving the same line in a file?
- What does
python3 hello.pydo? - What type does
inputreturn, and what does that mean when the user types19? - Why does the course ask you to record your Python version?
Answers
- A program is an ordered list of exact instructions that the computer follows in order. The Python course uses the same wording.
- The prompt runs each line as soon as you press Enter. A file runs all of its lines in order, from top to bottom, each time you run it.
- It starts the Python interpreter and gives it the file
hello.pyto run. inputreturns a string, which is text. The user typed19, and Python gives you the characters"19", not the number 19. You needintorfloatto get a number, and that comes in weeks 2 and 4.- Error messages and small details differ between Python versions. The course was tested on Python 3.12 and 3.14. If your output differs, your version is the first thing to check.