For example, Python uses + and * to represent addition and multiplication for integers and floating-point numbers Python uses and, or, and not to represent boolean operations and so forth. An operator is a Python-code representation of a data-type operation. It creates an object with the specified value. A literal is a Python-code representation of a data-type value. Python programs use object references either to access the object's value or to manipulate the object references themselves. An object reference is nothing more than a concrete representation of the object's identity (the memory address where the object is stored). For example, we can multiply two int objects but not two str objects. We can apply to an object any of the operations defined by its type (and only those operations).
For example, one object of type str might store the value 'hello', and another object of type str also might store the same value 'hello'. Different objects may store the same value. The value of an object is the data-type value that it represents.Įach object stores one value for example, an object of type int can store the value 1234 or the value 99 or the value 1333.The type of an object completely specifies its behavior - the set of values it might represent and the set of operations that can be performed on it.You should think of it as the location in the computer's memory (or memory address) where the object is stored. The identity uniquely identifies an object.Each object is characterized by its identity, type, and value. An object is an in-computer-memory representation of a value from a particular data type. All data values in a Python program are represented by objects and relationships among objects. The end result is that variable c is bound to an object of type int whose value is 1333.
This code creates three objects, each of type int, using the literals 1234 and 99 and the expression a + b, and binds variables a, b, and c to those objects using assignment statements. To do so, we start with the following code fragment: To talk about data types, we need to introduce some terminology. In this section, we consider Python's built-in data types int (for integers), float (for floating-point numbers), str (for sequences of characters) and bool (for true-false values). Many data types are built into the Python language. A data type is a set of values and a set of operations defined on those values.