Chapter 1
Getting Started with Python
Learn how programs turn a task into precise instructions and how Python runs those instructions. You will run small programs, read their output and errors, and make controlled changes without needing previous programming experience.
Programming begins with a task, a method for completing it, and instructions that express that method. Python is a programming language: a way to write those instructions so a compatible runtime can execute them. In machine learning, this lets us turn an idea or calculation into a program whose intermediate values and final result we can inspect.
This chapter begins in the browser, so you can run the first examples without installing anything. It then shows how to check Python on your computer, save code in a script, run that script from a terminal, and use an interactive Python session for quick questions.
The final lessons separate code from output, introduce simple error messages, and develop a useful programming habit: change one thing, run the program again, and compare the result with what you expected. That habit will support every later Python chapter.
After this chapter
- Explain the roles of a task, algorithm, source code, and runtime.
- Identify the input, processing, and output of a small program.
- Run a small Python script.
- Tell code apart from output.
- Use an interactive session for tiny checks.
- Read simple errors as debugging information.
- Edit one line, rerun, and explain the changed output.
Your learning
Lessons
- 01Programming and Python
Understand programs, algorithms, input, processing, output, source code, and the role of a Python runtime.
- 02How Python Reads and Runs Code
See how Python follows exact instructions, evaluates expressions, and displays output.
- 03Checking and Installing Python
Check for a supported Python interpreter and install it safely when needed.
- 04Scripts and the Terminal
Create a Python script, locate it from the terminal, run it, and diagnose common folder and filename problems.
- 05Using the Interactive Python Prompt
Use the Python prompt for quick checks, retained values, and small errors, then leave the session safely.
- 06Reading Python Output and Error Messages
Compare expected and actual output, then read a short Python traceback to locate and understand an error.
- 07Editing, Commenting, and Rerunning Python Code
Edit and rerun a Python program, inspect intermediate values, and write comments that explain useful intent.