import numpy as np
def f(*argv):
x=argv[0]
y=argv[1]
z=argv[2]
return x+y+z
f(*[0,1,2])
f(*[0,1,2,4])
def fArgs( *arguments):
res=0
for arg in arguments:
res+=arg
return res
fArgs(*[0,1,2,4])
def fNdim(*argv):
return np.sum(np.array(argv))
fNdim(*[0,1,2,4])
d={"orario":1600,"b":2}
d.keys()
d['orario']
d[0]
l=[12,34,0,33]
l[0]
def fDict(**keywords):
for kw in keywords:
print(kw, ":", keywords[kw])
fDict(**{"a":1,"b":2})
def fDictX(x,**keywords):
for kw in keywords:
print(kw, ":", keywords[kw])
return keywords['a']+x*keywords['b']
fDictX(0.1,**{"a":1,"b":2})
def fOptional(x=1,y=2):
print(x*y)
fOptional()
fOptional(x=3)
def gDict(**keywords):
# do ...
return fDictX(2,**keywords)
gDict(**{'a':'first','b':'second'})
def gOptional(**kwarg):
return fOptional(**kwarg)
gOptional(x=2,y=5,z=1)
def hOptional(debug=True,**kwarg):
print(debug)
return fOptional(**kwarg)
hOptional(debug=None)
hOptional(debug=1,x=55)