Module 05 — Functions: Abstraction in Business Analytics#

Graduate MSBA Module Overview

As analytics workflows grow more complex, repeating the same logic in multiple places becomes a liability — harder to maintain, easier to introduce errors, and inefficient to update. Functions solve this problem by encapsulating logic into reusable, named components.

A function is a block of code that takes inputs, performs a task, and returns an output. You define it once and call it as many times as needed. Functions embody the principle of abstraction — one of the four core programming principles in this course — because they hide complexity behind a clean, readable interface.


Course Connections#

Functions are also how professional analytics code is organized. When you encounter Python scripts from colleagues or AI tools, they are often structured around functions — with each one responsible for a specific task and designed to work together in a larger pipeline. Understanding how to read, write, and reason about functions is essential for modern analytics work.


Quick Code Example#

def calculate_customer_tier(total_spent, purchase_count):
    if total_spent >= 1000 and purchase_count >= 10:
        return 'Platinum'
    elif total_spent >= 500 or purchase_count >= 5:
        return 'Gold'
    else:
        return 'Standard'

def compute_average_purchase(purchase_list):
    if len(purchase_list) == 0:
        return 0
    return sum(purchase_list) / len(purchase_list)

customers = [
    {'name': 'Alice Johnson', 'total_spent': 1257.30, 'purchases': [250.50, 180.75, 420.25, 405.80]},
    {'name': 'Bob Martinez', 'total_spent': 430.50, 'purchases': [215.25, 215.25]},
    {'name': 'Carol Chen', 'total_spent': 890.75, 'purchases': [300.00, 290.75, 300.00]}
]

for customer in customers:
    tier = calculate_customer_tier(customer['total_spent'], len(customer['purchases']))
    avg = compute_average_purchase(customer['purchases'])
    print(f"{customer['name']} | Tier: {tier} | Avg Purchase: ${round(avg, 2)}")

Expected Output:

Alice Johnson | Tier: Platinum | Avg Purchase: $314.33
Bob Martinez | Tier: Standard | Avg Purchase: $215.25
Carol Chen | Tier: Gold | Avg Purchase: $296.92

Learning Progression#

PlatformStudent Learning Experience
NotebookLMExplore functions through business storytelling that shows how encapsulating logic into named, reusable components is both a technical skill and an organizational philosophy
Google ColabWrite, test, and call functions in Python, seeing how they accept inputs and return outputs
ZybooksBuild fluency with function syntax, parameters, and return values through structured practice exercises

Module Pages#

  • Concept → — Deep narrative on functions and abstraction
  • Advanced → — Extended code with a multi-function analytics pipeline
  • Notebook → — Jupyter notebook lab description