Learning to Code 01: Starting Out

Hey, I’m glad you’re here! 👋

If you’re new to the site, my name’s Tanner. I’m documenting my journey to learn how to code with the hope that it helps others like me who are coming to it with no real technical background.

For how many people know how to program in the world, I’ve been underwhelmed with the available resources for people like me who are essentially starting from zero.

One of the most common pieces of advice I’ve seen is “Just learn it as you’re building a project.” It sounds like good advice because, after all, action produces information. But that advice neglects one limiting question that I suspect many others like me ask in response… “What project(s) can I even build?”

I’m currently 27 years old, which means that I have roughly 40 years left in my working life. As I analyze the trends that have emerged in my lifetime, it’s obvious that the largest opportunities to create leverage and familial wealth exist in the programming/software development space. The Internet, social media, blockchain, SaaS, pretty much everything we interact with on a daily basis has code at its foundation. That trend isn’t reversing. If anything, it’s accelerating. In my mind, learning the skill is a critical component in insuring my downside — having a skill that can create value anywhere at anytime. I have more to say about that, but that’s something I can talk more about in the future.

I’m still early in this journey, but I’ve had a quote from Naval running through my head each time I sit down to code.

“Learn to sell. Learn to build. If you can do both, you will be unstoppable.”

Naval (Twitter)

When I think of “unstoppable”, I don’t view it as becoming an unstoppable force that crushes my competitors. Instead, I think of being unstoppable as always being able to create future opportunities for yourself.

You need all sorts of permissions to build a house; you need none to write code and ship it. Alas, my learning challenge.

That’s enough philosophy for now. Let’s get into how to get started.

Okay…I lied.

I don’t want to pretend that I’m doing this solely for the good of you, the reader. There’s also some selfish motivation behind writing this, and it’s found in the Feynman Technique.

The great thing about this is that it’s a positive-sum game where our incentives are aligned. The best kind of games.

Okay, for real now. Let’s get started.

Starting Out

So you’ve decided you want to learn how to code. Welcome!

There’s like a bajillion programming languages you could learn. If you’re a coach who wants to learn data analysis, you could choose either SQL, R, or Python.

Personally, I want to go down more of a software/app development track. Because of that, I chose Python as my starter language (I learned some basic SQL when I coached in the MiLB so I’m not starting from scratch).

I started out by going through some lectures on Free Code Camp. It’s what it sounds like — a free place to learn how to code. I enrolled in the Scientific Computing with Python Certification and worked my way through the first 13 lessons. It was fine, but IMO it was too much lecture & not enough doing.

I don’t have a lot of time to sit through video lectures, so I started looking for something else.

That’s when I discovered Sololearn. It has short lessons (each one takes about 5 minutes) and is very interactive. They teach you something and immediately ask you to put it into action on the next screen. Those short feedback loops between information input and output are exactly what I was looking for. As a bonus, they have a great iOS app so I can do a lesson wherever.

I don’t feel like the 13 Free Code Camp lessons were a waste, but it was just too much information without action — like a strength coach having every certification under the sun without taking 405 pounds for a ride (and occasionally getting buried).

What You Need to Download

A few days into my coding journey, I called our data analyst at Tread. “Cam, I’m trying to learn how to code in Python and I need your help. It feels like I need to download something, but I have no idea what and I can’t find that information anywhere.”

So Cam (the nicest, most patient person ever) taught me about these things called integrated development environment, or IDE’s. You can think of an IDE as Microsoft Word for code. It’s where you write the code, run the code & (most importantly) see the output of your code. There are a bunch of them out there, but Cam told me to get Microsoft Visual Studio and install the Python package. There was a nice walkthrough within MVS that helped me do that, but a quick Google search for “install Python in Microsoft Visual Studio” should help if you run into any trouble.

Now, if you took my advice and are using Sololearn, you won’t need an IDE for a while. Sololearn has their own IDE within the program so you won’t need to write code off-platform. A win for simplicity.

I recommend downloading Evernote and taking notes on each language you’re going to learn. Evernote has the ability to insert a code block into the note, which comes in handy when you forget if you need to indent after an if : statement. At the same time, avoid the temptation to take notes on everything. Pay attention to what’s resonating and try to explain things in your own words. That’s what I’m doing here.

Some Early Takeaways

I’m currently 13 lessons into Sololearn. Basically, I’ve caught up to where I was in Free Code Camp, but feel like I’ve gotten a significant benefit from the regular practice.

One of the things that I’ve been amazed by is how coding teaches you to think from first principles. Take this example from Sololearn’s lesson on else statements:

My assignment was to write a program to figure out whether a random year was a Leap Year or not. Here were the instructions:

You need to make a program to take a year as input and output "Leap year" if it’s a leap year, and "Not a leap year", if it’s not.

To check whether a year is a leap year or not, you need to check the following:
1) If the year is evenly divisible by 4, go to step 2. Otherwise, the year is NOT a leap year.
2) If the year is evenly divisible by 100, go to step 3. Otherwise, the year is a leap year.
3) If the year is evenly divisible by 400, the year is a leap year. Otherwise, it is not a leap year.

With what I know, I started attacking the problem head-on. My first attempt looked like this:

The logic behind it was pretty simple, at least in my human brain. If it’s evenly divisible (using the % operator), then proceed to the next step, then the next step, and finally print out ‘Leap year’.

But, that didn’t work. Because I had approached the program from the wrong direction.

As it turns out, the way to solve this problem was to actually evaluate if the year wasn’t evenly divisible by the denominator. This was the winning code:

So, let’s do an example.

The first line asks the user for a year and spits it out as an integer (instead of a string (AKA text), which is the type of data that the input() function usually produces).

We type in 2000. The year variable now equals 2000.

Python skips the next line because any line with a # in front is there as instructions for humans, not for the computer. It allows the person writing the code to explain what’s going on.

In line 3, Python takes 2000 / 4 and gets 500. Because there’s no remainder, it equals zero so it doesn’t print ‘Not a leap year’.

It goes onto line 5 and performs 2000 / 100. The answer’s 200 with no remainder, so Python doesn’t print ‘Leap year’ and moves onto the next line of code.

Similar story with line 7. 2000 / 400 = 5 with no remainder, so the print() function in line 8 isn’t triggered and it moves on to the final else statement in line 9.

The else statement is there as a catch-all. It exists to do something in the event that the program has gotten to that point. If the year was 1953, we lines 3 & 4 would’ve caught that and printed ‘Not a leap year’ a whole lot earlier. But 2000 has gotten this far, so we need to do something. We need to tell the user that 2000 was, in fact, a leap year.

So, the output of the program is ‘Leap Year’.

If you want to see this in action, go here, press the green “Run” button, type 2000 into the bottom section, and press ‘Enter’.

It’s basic, but it’s still so freakin’ cool.

Next Time

Next up on the Sololearn docket is Boolean Logic, while Loops, and break & continues. This was a fun post to write, and I’m looking forward to doing it again somewhat soon!

If you want to see all the posts in this Learning to Code series, click here.