Chapter 5 numbers and Chapter 5

Source: Internet
Author: User

Chapter 5 numbers and Chapter 5

5.1 numeric type
Numbers provide scalar storage and direct access. It is a type that cannot be changed, that is, the value of a change number will generate a new object. Of course, this process is transparent to both programmers and users, and does not affect the way software is developed. Python supports multiple numeric types: integer, long integer, Boolean, double-precision floating point, decimal floating point, and plural.

How to update numeric objects
Because you have not actually updated the original value of this object. This is because numeric objects cannot be changed. The object model of Python is somewhat different from the conventional object model. In your opinion, the update actually generates a new value object and gets its reference.
In the process of learning programming, we have been receiving such education that variables are like a box containing variable values. In Python, variables are more like a pointer pointing to a box containing variable values. For unchangeable types, you cannot change the content of the box, but you can direct the pointer to a new box. Every time another number is assigned to a variable, a new object is actually created and assigned to the variable. (This is not just a number, but for all the unchangeable types)
AnInt + = 1
AFloat = 1, 2.718281828
How to delete a numeric object
According to the Python rule, you cannot really delete a numeric object. You just don't use it anymore. If you
To delete a reference to a numeric object, use the del Statement (see section 3.5.6 ). Delete an object reference
You can no longer use this reference (variable name) unless you assign it a new value. If you try to use
The deleted object reference will cause a NameError.
Del anInt
Del aLong, aFloat, aComplex

5.3 double-precision floating point number
The floating point in Python is similar to the double type in C. It is a double-precision floating point. It can be expressed in decimal or scientific notation. Each floating point occupies 8 bytes (64 bits) and fully complies with the IEEE754 standard (52 M/11E/1 S). 52 bits are used to represent the bottom, 11 bits are used to represent the exponent (the value can be expressed in the range of about 308.25 to the power of plus or minus 10), and the remaining bits represent the symbol. This looks perfect, however, the actual precision depends on the machine architecture and the compiler that creates the Python interpreter. Floating point values usually have a decimal point and an optional suffix e (in upper or lower case, indicating scientific Notation ). Between e and an index, you can use positive (+) or negative (-) to indicate positive and negative values of the index. (If positive numbers are used, symbols can be omitted ). The following are examples of typical floating point values:
0.0-777. 1.6-5.555567119 96e3*1.0
4.3e25 9.384e-23-2.172818 float (12) 1.000000001
3.1416 4.2E-10-90. 6.022e23-1.609E-19

5.4 plural

The following are several concepts about plural in Python:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.