Utilizor
Contact Us

Python Functions

Blocks of reusable code.

Examples

Create and Call

Defining and calling a function.

def my_function():
  print("Hello from a function")

my_function()

Arguments

Passing arguments.

def my_function(fname):
  print(fname + " Refsnes")

my_function("Emil")
my_function("Tobias")

Return Values

Returning a result.

def my_function(x):
  return 5 * x

print(my_function(3))
print(my_function(5))

Test Your Knowledge

Python Quiz

No quiz available for this topic yet.