1. Introduction#
This chapter gives you a high-level view of what programming is, how Python fits into the broader computing landscape, and which ideas you will rely on throughout the book.
Programming as a way to express steps and decisions
Python as a readable, practical language
Jupyter as a place to experiment with code
Basic syntax as the notation for programming ideas
Built-in functions as ready-to-use tools
Common patterns as a first look at idioms you will meet in later chapters
Python is a practical first language because it lets you focus on problem solving without fighting the syntax too early. Its readability, standard library, and ecosystem also make it useful for automation, scripting, data analysis, and software development. This chapter has three sections: programming concepts, basic Python syntax, and a first look at common patterns.
Chapter Video
This introduction walks through installing Python and getting ready to run Python programs.
Python Tutorial for Beginners 1: Install and Setup for Mac and Windows (15:28) by Corey Schafer
Hosted on YouTube; property of its original creator, embedded here for educational reference only.
Learning Objectives
By the end of this chapter, you will be able to:
Explain what programming is at a high level
Describe how Python fits into the broader computing landscape
Distinguish conceptual programming ideas from Python-specific syntax
Identify where to find environment and Jupyter setup guidance
Use basic built-in functions in simple Python code
Recognize common Python patterns, such as context managers, list comprehensions, lambda expressions, and exception handling, when reading code
Read a basic Python error message to find the error type and the line that caused it
Describe the imperative paradigm and name the paradigms that later chapters add
Explain why reading and testing code still matters when an AI coding assistant writes it
Chapter Flow
Glossary
# |
Term |
Explanation |
|---|---|---|
1 |
Program |
A set of instructions written for a computer to execute. |
2 |
Algorithm |
A finite, ordered set of unambiguous steps that turns input into output. |
3 |
Programming language |
A formal notation for writing instructions that a computer can interpret or compile. |
4 |
Natural language |
A human language, such as English, that allows ambiguity and depends on context. |
5 |
Formal language |
A precisely defined language with strict syntax and meaning. |
6 |
Abstraction |
A simplified view that hides lower-level details so you can focus on the idea that matters. |
7 |
Interpreted language |
A language commonly run by executing source code through an interpreter. |
8 |
Compiled language |
A language commonly translated into another form before the program runs. |
9 |
Programming construct |
A basic building block used to express computation, such as a statement or expression. |
10 |
Expression |
A piece of code that produces a value. |
11 |
Statement |
A complete instruction that Python can execute. |
12 |
Programming paradigm |
A style of organizing a program, such as imperative, object-oriented, or functional. |
13 |
Imperative programming |
A paradigm in which a program is a sequence of commands that change state step by step. |
14 |
AI coding assistant |
A tool, such as ChatGPT, Claude, or GitHub Copilot, that generates or explains code from a natural-language request. |
15 |
Vibe coding |
Building software by accepting AI-generated code that seems to run, without reading or understanding it. |
16 |
Number system |
A way to represent numbers using a base and a set of digits. |
17 |
Binary |
A base-2 number system that uses only 0 and 1. |
18 |
Hexadecimal |
A base-16 number system often used as a compact way to write binary values. |
19 |
Character encoding |
A mapping between characters and numeric codes. |
20 |
Syntax |
The formal rules for writing valid statements in a programming language. |
21 |
Indentation |
Leading whitespace that Python uses to show block structure. |
22 |
Block |
A group of statements that belong together under a control structure or definition. |
23 |
Built-in function |
A function available in Python without an import, such as |
24 |
|
A built-in function used to display output. |
25 |
F-string |
A formatted string literal that can include Python expressions inside braces. |
26 |
|
A built-in function that reads text typed by the user. |
27 |
Code point |
The integer that represents a character in Unicode; for ASCII characters it equals the ASCII code. |
28 |
|
A built-in function that returns the code point of a single character, such as |
29 |
|
A built-in function that returns the character for a code point, such as |
30 |
Comment |
A note that starts with |
31 |
Docstring |
A string literal written as the first statement of a module, function, or class to document what it does. |
32 |
Keyword |
A reserved word, such as |
33 |
Soft keyword |
A word that acts like a keyword only in certain Python contexts but can still be used as a name elsewhere. |
34 |
Argument |
A value passed into a function call inside the parentheses. |
35 |
Return value |
The value a function call produces, which you can store in a variable or use in an expression. |
36 |
|
A special value that represents the absence of a value; a function without a |
37 |
Module |
A single Python file ( |
38 |
Package |
A directory of related modules that forms a larger namespace and is often installed with |
39 |
Context manager |
An object that sets something up, lets you use it, and cleans up afterward; the |
40 |
List comprehension |
A one-line expression that builds a new list from an existing sequence, optionally keeping only items that pass a test. |
41 |
Lambda expression |
A small function with no name, written on one line with the |
42 |
Conditional expression |
An expression of the form |
43 |
Exception |
An error that interrupts a program unless a |
44 |
Unpacking |
Assigning the items of a sequence to several variables in one statement, such as |
45 |
Positional argument |
An argument matched to a function’s parameter by its place in the call. |
46 |
Keyword argument |
An argument written as |
47 |
Error message |
The report Python prints when an error stops a program; its last line names the error type and what went wrong. |
48 |
Traceback |
The part of an error message that lists the lines Python was running when the error occurred. |