Jan 1, 2018

[Python] an example of function, module

def add3(a,b,c):  # define a function
 return(a+b+c)
print(add3(1,2,3),"\n")
 
 
def add(*vary):
 for i in vary:
  print(i)
add(1,2,3,4)

 

# if the above function is saved in add.py and you'd like to use it as a module,
#  import add
#  add.add3(1,3,4)
#
# if you'd like to directly use all functions in add.py,
#  from add import *
#  add3(2,4,5)

No comments:

Post a Comment