26
loading...
This website collects cookies to deliver better user experience
def function_name(self):
'''block of code in this function appear here'''
pass
def sum(num1, num2):
'''this adds two numbers'''
return num1 + num2
def sum(num1, num2):
'''this adds two numbers'''
return num1 + num2
sum(4,5)
def sum():
x = 10 #value inside the function
print(x)
y = 10 #value outside the function
print(y)
Built-in functions, such as help() to ask for help, min() to get the minimum value, print() to print an object to the terminal,… You can find an overview with more of these functions here.
User-Defined Functions (UDFs), which are functions that users create to help them out; And
Anonymous functions, which are also called lambda functions because they are not declared with the standard def keyword.
def my_function():
return "hello world" #this is a function.
class my_class:
def my_method(self): # this is a method
return "hello world"