Introduction to Python ProgrammingXYZ Homework Edition

⇩ Download ▾

Chapter 1: Statements

Photo of a mechanical keyboard and a computer screen, with part of the Python specification document shown on the screen.
Figure 1.1 credit: Larissa Chu, CC BY 4.0

Computers and programs are everywhere in today's world. Programs affect many aspects of daily life and society as a whole. People depend on programs for communication, shopping, entertainment, health care, and countless other needs. Learning how to program computers opens the door to many careers and opportunities for building a better world.

Programs consist of statements to be run one after the other. A statement describes some action to be carried out.

The statement print("Good morning") instructs Python to output the message "Good morning" to the user. The statement count = 0 instructs Python to assign the integer 0 to the variable count.

This chapter introduces statements for input and output, assigning variables, and basic arithmetic. Making mistakes is a normal part of programming, and the chapter includes advice on understanding error messages. The chapter ends with a short history of Python and discusses why Python has become so popular today.

Adapted from Introduction to Python Programming by OpenStax (openstax.org), licensed under CC BY-NC-SA 4.0. Changes were made. License: CC-BY-NC-SA-4.0.

These eBooks are a prerelease and are not yet certified conformant with WCAG 2.1 AA or any other accessibility standard. Every page is built against an automated accessibility gate, and our target for the published editions is WCAG 2.2 Level AA. If something is unusable, please tell us.