Basic data types for Python first knowledge

Source: Internet
Author: User

Python basic data type (0717)

1. Numbers:

Integer int: For example: grade, age, rank, etc.

float: Price, etc. (when using decimals)

2. String str:

Purpose: Descriptive data,

Value: string is a whole

The portion of a string that can be taken with an index or slice

string concatenation:

' String1 ' + ' string ' or string*3

3. List of lists

contained within [], each element separated by commas

Purpose: There are multiple values that can be modified for each element

Method:

List.append () #在尾部增加一个元素

List.remove () #删除指定的元素

Operation:

1. View, use the index;

2. Increase List.append ()

3. Delete the index of the List.remove (element) or del list[element]

4. Modify list[Index] = value

4. Dictionary Dict

Defined within {}, comma separated, each element in the form of Key:value

Dictionary:

Purpose: To store multiple values, similar to the list, the value can be any data type, key is immutable type;

Operation:

View: Dict[key] View the corresponding value

Added: Dict[key] = value

Delete: Del Dict[key]

Modified: Dict[key] = value (new value)

5. Boolean type True False

Purpose: Used to judge

For example:

If num > 50:

Print (' Hello World ')

Else

Print (' Wow ... ... ')

Not to be continued

      

    

  

  

Basic data types for Python first knowledge

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.