In [ ]:
In [1]:
def myfun():
print s
s = "this is a python class"
myfun()
In [3]:
def myfun():
s = "this is python funtions class"
print s
s = "this is a python class"
myfun()
print s
In [4]:
def myfun():
global s
s = "this is python funtions class"
print s
s = "this is a python class"
myfun()
print s
In [11]:
def myfun():
#global s
#print s
s = "this is python funtions class"
#print s
s = "this is a python class"
myfun()
In [12]:
s
Out[12]:
In [16]:
def myfun(a,b=0):
print a+b
c = myfun(3)
print c
In [24]:
def myfun(a,b=3):
print b
print b+a
c = myfun(a=5)
print c
In [28]:
def myfun(a,b, *c):
d=[]
d.append(a)
d.append(b)
[d.append(x) for x in c]
return d
c = myfun(3,4,5,6,7)
print c
In [29]:
print myfun
In [30]:
c = list
In [31]:
c
Out[31]:
In [32]:
c = myfun
In [33]:
for x in c:
print x
In [36]:
def myfun(a,b, *c):
d=[]
d.append(a)
d.append(b)
[d.append(x) for x in c]
return d
c = myfun
print c
In [37]:
for x in c:
print x
In [40]:
def myfun(*c, **d):
print c,d
c = myfun(5,6, class1="python", topic="functions")
print c
In [ ]: