Bringing it all together

Introduction to Functions in Python

Hugo Bowne-Anderson

Instructor

What you have learned:

  • How to write functions

    • Accept multiple parameters

    • Return multiple values

  • Up next: Functions for analyzing Twitter data

Introduction to Functions in Python

Basic ingredients of a function

  • Function Header
def raise_both(value1, value2):
  • Function body
    """Raise value1 to the power of value2
    and vice versa."""

    new_value1 = value1 ** value2          
    new_value2 = value2 ** value1

    new_tuple = (new_value1, new_value2)

    return new_tuple
Introduction to Functions in Python

Let's practice!

Introduction to Functions in Python

Preparing Video For Download...