user63719
0
Q:

how to make 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 your_function(arg1, arg2, arg3):
  do_something
  do_something_else

#to call the function (make it run):

your_function(something, something, something)
2
def myFunction():
  print('I am running in a function!')
14
def function_name():
  pass
2
# Example 1
def example_function(arg0): # create function with argument
  
  # print the argument gained from executing the function
  print(arg0)
  
example_function("hello") # execute function

# Example 2
def new_function(arg0=None): # create function with argument
  # arg0 = None : allow optional input
  
  if arg0 == "hello": # compare arg0 to "hello"
    return True # if comparrison success
  # return boolean values, ending function
  return False # if comparrison failure

check = new_function("hello") # get boolean value from function
-1

New to Communities?

Join the community