Python Beginners Day Collection, Hex

Source: Internet
Author: User

10day

Data type: Collection set

1, the definition of the collection

Collections: unordered, non-repeating combinations of data.

Feature: A, go to weight, put a list into a set, then automatically go heavy

b, the relationship test. Test the relationship between two sets of data, such as intersection, difference set, and set

2, the basic operation of the collection:

2.1 Create a collection:

s = {}

2.2 New

S.add () #若不重复则添加, if repeat is not added

S.update ([1,2,4]) #批量添加集合

S.copy () #复制一个集合

2.3 Delete

S.discard () #若有则删除元素, if no error

S.pop () #随机删除一个元素, if no error, return the deleted element

S.remove () #删除一个元素, if no error

S.clear () #清空

3, set of the relationship test

The relationship test of a set is divided into: intersection, difference set, set, symmetric difference set

3.1 Intersection: Two coincident parts of a set &

3.2 Difference set: In S1, not part of S2, there are two ways

The first type:-

S1-s2

Second type: S.difference ()

S1.difference (S2)

3.3 Set: There are S1 and S2 collections, there are two ways

First type: S.union ()

S1.union (S2)

The second type: | (Pipe character)

S1 | S2

3.4 Symmetric difference set: Only the set in S1 or S2 is present

S.symmetric_difference ()

4, the relationship between the set:

4.1 Subset: S.issubset () or S1>=S2

4.2 Superset: S.issperset () or S1<=S2

4.3 contains:

In,not in to determine whether an element is within a set

==,! = Determine if two sets are equal

4.4 Relationship:

There are generally three relationships between two sets: Intersect, disjoint, inclusive

The python species are judged by the following methods:

4.4.1 Disjoint: S.isdisjoint ()

Hexadecimal

1, 16 binary conversion

Binary: In the bin ()

Octal: 01234567 Oct ()

Hex: 0123456789ABCDEF Hex ()

---restore content ends---

Python Beginners Day Collection, Hex

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.