Just a cute pic of me
by Mike McKee
Programming

Challenge: Tell Me How This Python Function Works

66 Days of Math and Programming -- Day 35

Quick, quick, quick…

I don’t have much time today, so I should give up and not write today, right?

Nope.

That ain’t happening on my watch. (Cue me wagging my finger like Dikembe Mutombo)

I’m not giving up easily, but I’m also not writing a novel today.

So here’s what I’ve got for you, my fellow data dorky…

One of my favorite ways to understand Python better is by recreating functions that already exist. When you’re sorting a list or doing a search algorithm, you don’t have to write them. Python has built-in functions to do the dirty work for you.

But sometimes, doing the dirty work is nice.

It builds character (and helps you learn).

That’s why I recreate functions in my free time. (Sometimes, not always).

And yesterday, I remade a function that finds the Greatest Common Factor (GCF) between two numbers.

Okay, look…

Now’s normally the time I break down my code and explain why everything works. But I’m tired and lazy. So instead, I’m giving you the code and encouraging you to understand how the function I created works.

What do you think?

Up for the challenge, you data dork?

Python function to find the GCF for two numbers