content will be learn:
how to use set.
set is a object ,characters :not be repetitive,can be hashing.
startup in two way :
set () can be add and delete
frozenset() can not be change,not be update and remove
set () :use to intersection,union set ,aperation to achieve our goal
a=set('suny)
a.add('go‘)。old set ,have four elements:'s','u','n','y'
renew set :have five elements:'s','u;,'n','y','go'
a.update('go').old set hvae four elements:'s',;u;,'n;,;y;
renew set have six elements:'s;'u','n','y','g','o'
remove,del
set() operation characters:
in ,not in == != :return Boole value 'True' 'False'
,subset (subaggregate subcollection)superset: can use to remove duplicates.de-weight.
calling set () :
for i in set():
print(i)
subset(subaggregate,subcollection),operation characters
set()>set()
set() in set()
combin two more set().can use operate union() or
union and or is equivalent.
operation characters:
set() | set()
s1.union(s2)
intersection:
operation characters:
set()&set()
s1 . intersection(s2)
check set :
operation characters:
difference
s3=s1-s2
s1 . difference(s2)
symmetric difference set()
operation characters:
s3=s1^s2
s1 . symmetric.difference(se)
subroutine,subaggregate
function parameters:
category:
form parameters; for example. def function(a,). this way 'a' is a form parameters.
actual parameters(actual argument): function(1,2).this '1,2' is actual parameters.
default parameters: instance: def function( sexuality='male') this 'sexuality' is default.
uncertain parameters: def function (*args) this ' *args' is uncertain parameters.
can be assignment(evaluation,valuation)
*args can be assignment unnamed parameters or untitled parameters. for example 19 'male'
def function (*args)
a=[1,2,3]
function(a) express for ([1,2,3],)
function(*a) express for (1,2,3)
if function (*[1,2,3} show for [1,2,3] same to function assignment list
**args can be assignment named parameters.or titled parameters. for example name=' alan'
def function(**kwargs):
a={}
function(**a) can express for { }
placeholder:
placeholder characters: %s usage: print(' you can go to %s'% parameters)
the position have many parameters can express as " go to %s,%s"%(parameter,parameter)
formal parameters and actual parameters corresponding relation: one position formal parameter corresponding one actual parameter.