Python development "Fourth": Functions of Python basics

Source: Internet
Author: User

########## #三元运算 ##########

Format: result = value 1 if condition else value 2 #如果条件成立, assign value 1 to the result variable, otherwise assign value 2 to the result variable

########## #基本数据类型补充 ############set:

Set set, which is an unordered and non-repeating element collection amount

1.add: Adding elements

Results:

2.clear: Clear Content

Results:

3. (1) Difference: Find different elements and assign them to new values

Results:

(2) Different_updata: Find different elements and update yourself

Result: {33,44}

{55,66}

4.discard: Delete Element

Results:

The difference between discard and remove is that discard can delete the set without the element, without error. and remove cannot delete elements that are not in the collection.

5. (1) Intersection: Take intersection

Results:

(2) Intersection_updata: Take the intersection and update yourself

Results:

6.isdisjoint: If there is no intersection, if there is no return true, if there is a return false

Results:

7. (1) Issubset: Determine if it is a sub-collection

Result: True

(2) Issuperset: Determine if the parent collection

Result: True

8. (1) Pop: Remove the last set

Result: #因为集合是无序的, so the last one is not necessarily 44

(2) Remove: Removes the specified element, no error is present

Results:

9. (1) Symmetric_difference: symmetric difference Set

Results:

(2) Symmetric_difference_updata:对称差集,并更新到自己中

Results:

10.union: The Set

Results:

11.updata: Update

Python development "Fourth": Functions of Python basics

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.