程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python childrens programming improvement articles (4) collection

編輯:Python

Python Children's Programming Class (14)
Improvement (4) Collection


Collection

Abbreviated as a set, it is a "determined bunch of things", and the "things" in the collection are called elements.It is also a basic concept in mathematics and the main research object of set theory.A set that does not contain any elements is called an "empty set".

In python, sets are defined with {items,...} or set(iterable); empty sets can only be represented by set(), not {}.

>> set1 = {1,2,3}>>> set2 = set([1,2,3])>>> set1{1, 2, 3}>>> set2{1, 2, 3}>>> set0 = set()>>> type(set0)>>> type({}) # {} means empty dictionary

Features

Certainty

Given a set, give any element, the element either belongs to the set or does not belong to the set, the two must be one of the two, and no ambiguity is allowed.

Mutuality

In a set, any two elements are considered to be different, that is, each element can only appear once.Sometimes it is necessary to characterize the situation where the same element appears multiple times, and multiple sets can be used, in which elements are allowed to appear multiple times.

Disorder<


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved