Robot Thoughts
Published in

Robot Thoughts

Learn Practical Programming: The Basics

Vital tactics and concepts before diving into coding

Photo by Bret Kavanaugh on Unsplash

So you feel ready to start learning to code. However, even though that attitude is the key to learn programming, we need to set some ground rules. This is because there is a great majority of the people who start learning who end up quitting.

This happens because most people learn to code before they learn to avoid getting lost and trust me, it is insanely easy to get lost when coding. Therefore, before getting all hands-on the computer, we’ll see one of the best tactics to help us know what is happening and where we are at all times.

Test-Driven Learning

There’s a practice in coding called “test-driven development”, it consists in before making a program A, the developer creates another little program to check that program A is working properly, and if it isn’t, this little checking program indicates the developer where is the flaw in program A.

I do believe this is a good practice, in fact, it could be the best coding practice ever, yet disregarding my preferences, the point of following the test-driven development methodology helps coders avoid getting lost attempting to find errors and forces them to be structured while programming.

We’ll go over TDD (Test-Driven Development) in the next lesson. However, I’ve found that this methodology is useful for learning as well. Therefore, we’ll learn by defining some tests, and then we’ll see how those tests can be solved, and repeat the process until the concept is complete. So if you aren’t getting something right, please go back until you can solve the exercises and tests correctly. This way you’ll guarantee that you’ll learn and you won’t get lost.

Ready? Set? Go!


I won’t waste your time with dictionary definitions and similar stuff. Instead, I’ll give you my definition of programming/coding, it won’t be the best definition, but I promise it’ll be as simple as possible.

Programming (verb): The act of creating a program.

I know, it looks stupid, but I promised the simplest definition, which allows me to go to a more important word. This is where things start to get more interesting.

Program (noun): A set of instructions for computers which usually receive an input, do something, and return something else.

Now, let’s focus on the words “A set of instructions”. These words are the key to what is known as an algorithm. This is where we, as programmers, work most of the time.

Photo by Matt Artz on Unsplash

The Algorithm

As we mentioned before, the key to an algorithm is understanding that it’s just a set of instructions, and nothing else. Quite easy, right? Trust me, this can (and will) get harder, but for the moment let’s keep it simple. However, before diving into examples, you must know that these sets of instructions have some special rules. They need a starting and an ending state. It’s like going to buy cheese, you enter the store with money (your starting state) and you leave with a bag full of cheese (your ending state).

Let’s go through an example.

The Piña Colada Algorithm

PiñaColada(pineapple juice, rum, coconut cream, ice):

  1. Add the ingredients into a blender
  2. Turn on the blender for 30 seconds
  3. Pour into a tall glass
  4. return(a delicious glass of piña colada)

Notice how the first line of the algorithm contains some parenthesis with the ingredients inside, that is the starting state and the ingredients are something known as parameters.

Then, we have the instructions to make the piña colada, and in the end there is a final line saying “return” with the piña colada glass inside the parenthesis. This means that the “program” returns a glass of piña colada.

Obviously, this example is quite ambiguous, real algorithms are super-specific because even though you understand those words, the computer doesn’t know how to add the ingredients into a blender, how to turn on the blender, or how to pour into a glass. We’ll learn to be as specific as necessary later.


Now it’s your turn to write an algorithm. Your task is to write one to read a book. Then, do the same algorithm but make it 3 instructions longer than the first one. And as the last step, make it 5 instructions longer than the second one. This will give you an idea of how to start getting specific.

Try it and then we’ll go over as how I solved it (don’t worry, it doesn’t have to be exactly like mine).


Here’s my first version of the algorithm

The second version of my algorithm (notice how I made a substituted the return(book) for leaving the book in the bookshelf and then returning an empty parenthesis).

And finally the third version.

Don’t worry if you feel a little confused about the “while” instructions. We’ll go over them later. The objective of this exercise is to help you realize how there are multiple levels of ambiguity. Some programming languages are more flexible than others. In this course, we’ll use one called Python, which is one of the most flexible and powerful nowadays.

For this lesson, I won’t leave you a test because this concept is still part of the introduction. In the next post, we’ll talk about variables and operations. We’ll start making algorithms that return verifiable results, so we’ll start implementing the Test-Driven Learning methodology I mentioned. But for now, let the concept we saw today sink in.

I hope you liked this post don’t forget to follow this publication to receive notifications of the next steps of the course and amazing articles on science, technology, programming, AI, sci-fi, and anything in between.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


I’m a computer science student and I write about programming, roleplaying games, sci-fi, movies, books, finances, and anything that comes into my mind.