Book Image

Python Essentials

By : Steven F. Lott
Book Image

Python Essentials

By: Steven F. Lott

Overview of this book

Table of Contents (22 chapters)
Python Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Expressions, operators, and data types


Python expressions are built from operators and operands. In Chapter 2, Simple Data Types, we introduced some of the basics of number and string operands, and looked at the variety of operators. We'll summarize the details here so that we can address some additional operator features.

Our numeric operands form a "tower", with types including:

Type

Cardinality

Number of operators

complex

Ideally, the most distinct values built from a pair of irrational numbers, ∞×∞.

Actually (float × float) or about values.

The fewest operators; only arithmetic, some built-in functions, and the cmath module.

float

Ideally this is a rational number union with irrational numbers (∞+∞).

Actually closer to distinct values.

Arithmetic operators, comparisons. Many additional math modules and built-in functions.

fractions.Fraction

Ideally, these are rational numbers (∞×∞).

Actually only limited by available memory to represent two integers.

Arithmetic operators...