7.2 Expressions

Expressions in a programming language are combinations of data and operators. Operators are special symbols that have a specific meaning in the programming language. These operators perform computations on one or more pieces of data to produce a new piece of data. When the program carries out all of the calculations associated with operators in an expression, the result is a new piece of data whose value is the result of the expression.

It might sound pretty abstract, but you’ll find that you’re already familiar with a lot of the operators that we’re going to discuss. For example, 1 + 2 is a simple and valid Python expression. The + sign is the operator in this expression, and it works as you might expect; it combines the two data values, 1 and 2, using the rules of addition. The value of this expression is the integer number 3.