Operators

Recall from Chapter 2 our definition of expressions as simple statements that return a value. In Python, many expressions use operators, such as +, –, *, and =. The following subsections describe each operator type, and each section contains a table of the type's operators along with sample interactive sessions illustrating their use. If you feel as if you've been this way before, you have—we've been using operators since Chapter 1.

Arithmetic Operators

Arithmetic operators work with the numeric types Float, Int, and Long. Table 3-1 describes them, including three we have yet to encounter: modulus (%), which gives the remainder; exponential (**), which raises one number to the power of another number; and abs, which gives a number's ...

Get Python Programming with the Java™ Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.