Chapter 1. Programming as a Way of Thinking
The first goal of this book is to teach you how to program in Python. But learning to program means learning a new way to think, so the second goal of this book is to help you think like a computer scientist. This way of thinking combines some of the best features of mathematics, engineering, and natural science. Like mathematicians, computer scientists use formal languages to denote ideas—specifically computations. Like engineers, they design things, assembling components into systems and evaluating trade-offs among alternatives. Like scientists, they observe the behavior of complex systems, form hypotheses, and test predictions.
We will start with the most basic elements of programming and work our way up. In this chapter, we’ll see how Python represents numbers, letters, and words. And you’ll learn to perform arithmetic operations.
You will also start to learn the vocabulary of programming, including terms like operator, expression, value, and type. This vocabulary is important—you will need it to understand the rest of the book, to communicate with other programmers, and to use and understand virtual assistants.
Arithmetic Operators
An arithmetic operator is a symbol that represents an arithmetic computation. For example, the plus sign, +, performs addition:
30+12
42
The minus sign, –, is the operator that performs subtraction:
43-1
42
The asterisk, *, performs multiplication:
6*7
42
And the forward slash, /, performs ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access