user14044
0
Q:

how to define a function in python

def test_function(argument1,argument2,argument3) :
  # Do something with the code, and the arguments.
  print(argument1)
  print(argument2)
  print(argument3)
  
# Calling the function.

test_function('Hello','World','!')

# Output
'''
Hello
World
!
'''
11
def example():			#This defines it
  print("Example.")		#This is the defined commands

example()				#And this is the commands being run
17
def print_msg(msg): # This is the outer enclosing function
    
    def printer():# This is the nested function
        print(msg)

    return printer  # this got changed

# Now let's try calling this function.
# Output: Hello
another = print_msg("Hello")
another()
5
def your_function(arg1, arg2, arg3):
  do_something
  do_something_else

#to call the function (make it run):

your_function(something, something, something)
2
def function_name():
  pass
2
def add(number):
  equation = 5 + number
  print(equation)
  
 
add(10)

output:
  
  15
  
0
def a_function(input1):
  return input1 * 2
0

New to Communities?

Join the community