Intro Python: Functions

Learn how to write functions — and how those functions work behind the scenes.

About The Course

If you’re programming in Python, then you’re probably writing functions. The good news is that this is fairly straightforward; it’s not unusual to start writing functions in the first day of a Python course. But Python functions are also powerful and flexible, and that’s where things can get complex. 

Underneath the basic syntax are a variety of capabilities that are easy to use, if you know where to look and how to think. This course is all about understanding Python functions, how they work under the hood, and how you can take advantage of this knowledge in your own programs. 

Among other things we discuss in this course are:

 – Functions as nouns, not just verbs

 — treating functions as objects

 – How arguments are mapped to parameters 

– Working with Python’s local, global, and builtin variable scopes

 – Writing functions that take optional arguments

 – Dispatch tables, and how they can make your life easier 


This course is based on the material that I teach on a regular basis at Fortune 500 companies around the world. It’s meant for someone who already has a good sense of Python’s fundamental data types and syntax, and who wants to write functions that are simpler(?) than “Hello, world” and which can take advantage of Python’s many sophisticated features. The course includes a wide variety of exercises, based on questions I’ve given to my corporate-training clients over the years. As you solve these problems, you’ll gain insights into how to write more efficient, readable, and idiomatic functions in Python.

This Course Will Show You How To...

_check-box

How to write Python functions

_check-box

How arguments are mapped to parameters​

_check-box

The seven different types of Python parameters

_check-box

Dispatch tables, and how they can make your life easier

_check-box

Working with Python's local, global, and builtin variable scopes

_check-box

Writing functions that take optional arguments

_check-box

Passing functions as arguments to other functions

Preview The Course

Defining basic functions

Docstrings

*args

Course Contents

Course Length

4 Hours

Number of Lessons

46

Training Materials

9 PDFs

Coding Exercises

11

  • Introduction (3 mins)
  • What are functions? (4 mins)
  • Functions are objects (6 mins)
  • defining basic functions (6 mins)
  • functions return None by default (6 mins)
  • Return values (7 mins)
  • Returning multiple values (4 mins)
  • Docstrings (4 mins)
  • Positional arguments (7 mins)
  • Checking argument types (7 mins)
  • Defaults and multiple defaults (8 mins)
  • Exercises 1 (3 mins)
  • Exercises 1 solutions (11 mins)
  • Call by reference, or call by value? (8 mins)
  • the perlis of mutable defaults 
  • *args (11 mins)
  • Turning a sequence into arguments (5 mins)
  • Keyword arguments with *args (3 mins)
  • Exercises 2 (3 mins)
  • Exercises 2 solutions (11 mins)
  • Positional vs. keyword arguments (5 mins)
  • **kwargs (5 mins)
  • Avoiding repeated names (3 mins)
  • Where do we use **kwargs? (6 mins)
  • Exercises 3 (2 mins)
  • Exercises 3 solutions (6 mins)
  • combining argument types (5 mins)
  • Using ** when invoking functions (3 mins)
  • Positional-only arguments (4 mins)
  • Introduction to scoping (5 mins)
  • Global variables (6 mins)
  • Global variables from within functions (5 mins)
  • Local variables (6 mins)
  • Unbound variables (6 mins)
  • The “global” declaration (5 mins)
  • Using __main__ for global variables (5 mins)
  • Modifying globals(5 mins)
  • The buitins scope (12 mins)
  • Exercises 4 (2 mins)
  • Exercises 4 solutions (7 mins)
  • Custom sorting (7 mins)
  • Accepting functions as arguments (11 mins)
  • Dispatch tables (8 mins)
  • Exercises 5 (2 mins)
  • Exercises 5 solutions (10 mins)
  • Conclusion (1 min)

This Course Is Perfect For...

_check-box

Beginning developers ready to learn Python

_check-box

Advanced Developers looking to solidify their core skills

_check-box

Companies and teams wanting more productivity

_check-box

Companies and teams wanting more productivity

GET STARTED NOW

Monthly

Annual

Save 20%

BUY THIS COURSE

One-Time Purchase (Lifetime Access)
$ 180 One-Time
  • Defining functions
  • How arguments are mapped to parameters
  • Understand variable scoping

OR

GET A MEMBERSHIP

Access All My Training
$ 40 Per Month
  • All my Python courses
  • Monthly office hours + special events
  • Private forum

BUY THIS COURSE

One-Time Purchase (Lifetime Access)
$ 180 One-Time
  • Defining functions
  • How arguments are mapped to parameters
  • Understand variable scoping

OR

GET A MEMBERSHIP

Access All My Training
$ 400 Per Year
  • All my Python courses
  • Monthly office hours + special events
  • Private forum

100% Money Back Guarantee

I’m a one-person company dedicated to improving your career via Python and related technologies. If you haven’t gotten value from any of my courses, then just tell me — and I’ll refund your money.

Meet Your Instructor

Reuven is a full-time Python trainer. In a given year, he teaches courses at companies in the United States, Europe, Israel, India, and China — as well as to people around the world, via his online courses.

Reuven created one of the first 100 Web sites in the world just after graduating from MIT’s computer science department. He opened Lerner Consulting in 1995, and has been offering training services since 1996.

In 2020, Reuven published “Python Workout,” a collection of Python exercises with extensive explanations, published by Manning. He’s currently finishing edits on “Pandas Workout,” a similar collection of exercises using the “Pandas” library for data analytics.

Reuven’s free, weekly “Better developers” newsletter, about Python and software engineering, is read by more than 30,000 developers around the globe. His “Trainer weekly” newsletter is popular among people who give corporate training.

Reuven’s most recent venture is Bamboo Weekly: Every Wednesday, he presents a problem based on current events, using a public data set. And every Thursday, he shared detailed solutions to those problems using Pandas.

Reuven’s monthly column appeared in Linux Journal from 1996 until the magazine’s demise in 2019. He was also a panelist on both the Business of Freelancing and Freelancers Show podcasts.

Reuven has a bachelor’s degree in computer science and engineering from MIT, and a PhD in learning sciences from Northwestern University. He lives in Modi’in, Israel with his wife and three children.