Python core Programming-fourth chapter-Exercise

Source: Internet
Author: User

1. Identity, type, value. Where identity is the identity of each object, is closely related to the memory address, the available ID () is returned, and the type determines what type of value the object can hold, using the type () function, the isinstance () function to get the object's type, and the value is the data represented by the object.

2. Cannot change the value after the object creation is not updated. In Python, lists, dictionaries can be changed, numbers, strings, tuples are immutable

3. Type

strings, lists, and tuples are accessed sequentially, that is, attributes that have slices.

A mapping Type (dictionary) is a sequence-like index, but its index is not sliced in sequential numbers, but is accessed through a unique key or keyword, which holds a collection of hash-value pairs.

4.type () returns the type of the given parameter. The return is actually a type object that outputs a string

5. In many cases, they return the same. The difference is that the object returned by STR () is user-friendly and more suitable for print. Repr () Returns an object that is system friendly, returns an "official" display of a string, and in most cases can be re-acquired with Eval ().

Repr () is basically equivalent to the anti-quote "'

6. Type (a) = = Type (b)

Call two times the type () function and compare the two

Type (a) is type (b)

Comparing objects with object identities is worth comparing and improving the efficiency of Python

7. Slightly

8. The same points are arrays, which are container types, are read sequentially, accessed, and have slicing operations.

The difference is that the value of the list can be updated, mutable, tuples are not updatable, immutable

9.

 is btrue  is dtrue  is Ffalse

Python caches a range of simple integers, and Python does not create new objects when assigning values to C and D, so comparing the identities of a, B objects, or C, D objects is the same as the result.

In Python 2.7, the cache range is (-5,256)

Python core Programming-fourth chapter-Exercise

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.