Lesson Three: Python basic data Type lectures (1/3)

Source: Internet
Author: User


1. Python All objects
The whole of the methods that contain a series of data and manipulate the data is called an object

2. Composition of data types
Composed of three parts
Identity ID View unique identifier, memory address by this Oh!
Type types can take a look at
Value data item

The proud conclusion in a book is that everything in Python is a pointer, so there's no need to think about pointers.

3. Common basic data types
int integral type
Boolean Boolean type
String character type
List lists
Tuple tuples
Dict Dictionary


4. Data type is not variable
Immutable Type: int Boolean string tuple
Variable type: List Dict

The following ID (b) has not changed

>>> B = [1, "a", 234]
>>> ID (b)
40771336
>>> b[2]= "Asdfa"
>>> b
[1, ' A ', ' ASDFA ']
>>> ID (b)
40771336
5. Assigning values to variables everything is quoted, dynamic and dynamic types why not in the dynamic
Dynamic, defined after the type is OK, do not need to declare beforehand. However, after the definition cannot be converted dynamically

>>> a = "1234"
>>> a+1
Traceback (most recent):
File "<stdin>", line 1, in <module>
Typeerror:cannot concatenate ' str ' and ' int ' objects
>>> Int (a) +1
1235
>>>
6. Type conversion int Boolean
Print 1==1 True
A = bool (1==1)

Lesson Three: Python basic data Type lectures (1/3)

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.