Link to Replit (fork it to duplicate)

Example

def sayHello(name):
  print("Hello " + name)

def addNumbers(num1, num2):
  result = num1 + num2
  return result

sayHello("Ben")
sayHello("Sam")

valuesAdded = addNumbers(5432, 6432)
valuesAdded2 = addNumbers(5432432, 6432432)
print(valuesAdded2)

Summary

In this video, the speaker introduces functions in Python, explaining how they wrap up code for reuse. They demonstrate creating a simple function “say hello” and passing a variable “name” to personalize the output. The concept of returning values from a function is also covered, showing how to create a mini calculator function that returns the result for later use. The video emphasizes the convenience of functions for organizing and reusing code efficiently. Overall, the tutorial provides a clear and practical introduction to functions in Python, showcasing their versatility and usefulness in programming.