Introduction

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:

  1. Explain what programming is at a high level

  2. Describe how Python fits into the broader computing landscape

  3. Distinguish conceptual programming ideas from Python-specific syntax

  4. Identify where to find environment and Jupyter setup guidance

  5. Use basic built-in functions in simple Python code

  6. Recognize common Python patterns, such as context managers, list comprehensions, lambda expressions, and exception handling, when reading code

  7. Read a basic Python error message to find the error type and the line that caused it

  8. Describe the imperative paradigm and name the paradigms that later chapters add

  9. 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 print, input, len, or round.

24

print

A built-in function used to display output.

25

F-string

A formatted string literal that can include Python expressions inside braces.

26

input

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

ord

A built-in function that returns the code point of a single character, such as ord("A") returning 65.

29

chr

A built-in function that returns the character for a code point, such as chr(65) returning "A".

30

Comment

A note that starts with # and is ignored by the Python interpreter.

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 if, for, or class, that has special meaning in Python and cannot be used as a variable name.

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

None

A special value that represents the absence of a value; a function without a return statement returns None.

37

Module

A single Python file (.py) containing code such as functions, classes, and variables that you can import.

38

Package

A directory of related modules that forms a larger namespace and is often installed with pip.

39

Context manager

An object that sets something up, lets you use it, and cleans up afterward; the with statement runs one.

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 lambda keyword.

42

Conditional expression

An expression of the form a if condition else b that picks one of two values.

43

Exception

An error that interrupts a program unless a try statement handles it.

44

Unpacking

Assigning the items of a sequence to several variables in one statement, such as x, y = point.

45

Positional argument

An argument matched to a function’s parameter by its place in the call.

46

Keyword argument

An argument written as name=value and matched to a parameter by name, such as sep="-" in print().

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.

Lecture Slides

Chapter 1 Slides