DEV Community

Cover image for A Complete Beginner's Guide to Programming
Ali Spittel
Ali Spittel

Posted on • Updated on • Originally published at

A Complete Beginner's Guide to Programming

This post may seem out of place on a site for programmers, but I wanted to write something from zero. What even is programming? And, what are the building blocks of programming?

This post is going to start out by discussing what computers are at a conceptual level, and then discuss the programming fundamentals. We'll use Python in this post, but a lot of the building blocks work across programming languages, so this will still help even if you are interested in learning a different language at first.

What is programming?

You probably interact with computers on a daily basis, but let's define concretely what we mean when we talk about computers in relation to programming. A computer is a machine that processes and stores information.

Programming is telling the computer how to ingest, process, and then store that data. When someone writes a program, that person is giving the computer a set of commands that it must follow.

When we write programs, we are writing instructions that the computer will follow. Computers are very literal -- they will take our instructions and follow them exactly, but we must lay them out in a very detailed way so that they understand us.

Programming, at its core, is taking a big problem and breaking it into smaller and smaller problems until they are small enough that we can tell the computer to solve that problem.

Where can you see programs in use?

Everywhere! From your operating system on your computer through complex websites, all are written using code! Older (and newer!) cell phones, fancy coffee machines, self-driving cars, Facebook, Amazon, an ATM, the Lyft App, metro card reloaders, supermarket scanners, and most TVs use code to run in addition to your desktop or laptop computer.

What are programming languages?

Computers can't understand natural language by default, though they are getting closer and closer to being able to!

At their root, computers run on a series of microscopic on and off switches, and when we write code we are toggling them on and off -- just like a light switch! Computers use a numerical system called binary to use these on and off switches. Binary is a numerical system comprised of 1s and 0s in countrast to our decimal system which uses 0-9.

Thankfully, a lot of really smart people before our time thought of a way that we can talk to our computers without zeros and ones. Instead, we use programming languages which can be interpreted by our computer, similar to how language interpreters can translate Spanish to English or even English to sign language. These look a lot more like English than binary, but they still have a lot more symbols and fewer ways of doing things than natural language.

There are tons of programming languages out there, similar to how there are lots of languages spoken around the world. Some, like Assembly or C are very low level and don't really resemble how we speak. Others, like Python and Ruby closely resemble human language. These languages are used for different tasks, for example HTML, CSS, and JavaScript are used to write websites whereas C is used to write your operating system. These have evolved a lot over time -- old programmers used to have to use punch cards and feed them to the computer instead of typing out code on their computers! There are trade-offs between performance and ease of use, but when you learn how to code I would highly recommend one that is closer to normal language!

The Key Fundamentals for Programming

There are some fundamental concepts that move with us from programming language to programming language. We'll use Python, but pretty much every language know of has these fundamentals, though they may be written differently (outside of HTML and CSS which are pretty different).

Brief aside, you can run Python in your web browser using You can create a Python project by pressing the new repl button, and selecting Python. Then, type in the area under You then can run your code with the green run button.

You can also install Python on your computer by downloading it, and then using a text editor -- my favorite is VS Code. You would then run the code via the command line. You would create a file with a .py extension, then write your code in your editor, finally, you would run the file by running python

Hello World

When you learn a new programming language, it's a tradition to write a hello world program. So let's write one in Python!

There's a function in Python that allows us to write text to wherever we're running our code -- so if you're using the command line, it will print out there, if you're using, it will print out on the right-hand side of your screen.

We'll talk about what functions are in a bit!

print("Hello, World!")
Enter fullscreen mode Exit fullscreen mode

All of the code samples are also available in repl.its, but are linked instead of embedded


Variables are a very important piece of programming. Variables store a piece of information that you can use over and over again. If you remember variables from algebra class, they're the same thing conceptually!

In Python, in order to set a variable, we'll write a variable name (in this case name and age), then use an equals sign to set that variable to a value -- in the example "Ali" and 24.

If we use letters, we need to put them in quotes. If we want a number instead, then we'll keep them out of quotes.

name = "Ali"
age = 24

Enter fullscreen mode Exit fullscreen mode

Now, whenever we can use name or age wherever in our code!

Remember from above, programming languages are for humans, not just the computer. If we were just talking to the computer, then we'd just use 0's and 1's and write binary! So, remember to use variable names that will make sense to future you -- or another programmer who reads your code in the future.

Rule of thumb for variables: If you're going to use a value over and over, create a variable for it!

Data Types

There are different types of data that we can use when programming. Some common ones are integers, floats, booleans, and strings.


Integers are another math class term - they're basically numbers without decimals. So 1, 0, -100, 200, etc.

We can use integers in Python by just typing numbers!

Enter fullscreen mode Exit fullscreen mode

We can store them in variables, like we saw above, so that we can use them over and over again.

my_favorite_number = 22
Enter fullscreen mode Exit fullscreen mode

We can also do math with them! The four basic symbols are * for multiplication, + for addition, - for subtraction, and / for division.

print(22 + 10)

pieces_of_candy = 20 - 5
Enter fullscreen mode Exit fullscreen mode


Floats are numbers with decimals -- so 4.0, 4.5, -19.6 etc. They work like numbers otherwise!


Booleans are True and False in Python -- these are mostly used to say "yes" or "no" -- remember how computers are a bunch of on and off switches? Booleans are similar!

We can set variables to booleans, but it's usually more useful to compare values and see the results as booleans. One common use is checking equality. Is some variable equal to some value? We use double equals signs to check equality since we use one equals sign to set a variable.

age = 22
print(age == 22) # True
Enter fullscreen mode Exit fullscreen mode

We can also check greater than or less than -- or all those mathematical checks. We use > for greater, < for less, >= for greater or equal, and <= for less or equal!

print(5 > 10) # False
print(10 >= 10) # True
Enter fullscreen mode Exit fullscreen mode

We can also store booleans to variables!

is_greater = 5 > 10
print(is_greater) # False
Enter fullscreen mode Exit fullscreen mode

Things after hashtags in Python are comments -- they're ignored by the computer and are there as notes for yourself or other developers!


Strings are text in Python. We wrap them in quotation marks!

my_string = "This is a string!"
Enter fullscreen mode Exit fullscreen mode


Sometimes, we want to store more than one value in a variable -- say a collection of numbers, the names of the people in a room, the most recent tweets on twitter, or the prices of the items in our shop.

We can store these values in lists in Python!

items_in_store = [5, 10, 15, 8]
dev_employees = ["Ali", "Jess", "Ben", "Peter", "Andy", "Mac", "Liana", "Michael", "Anna", "Mario"]
Enter fullscreen mode Exit fullscreen mode

Rule of thumb for lists: If you have a group of similar things, put them in a list


Another key part of programming is conditionals. These allow us to run blocks of code sometimes and other blocks other times.

So, if a condition is True, run a block of code. Maybe, if something else is true, run a different block of code. Finally, if all the other ones aren't True, run this other block of code.

In Python, blocks of code are indented, so "if this thing is True, run the indented code after it"

name = "Ali"

if name == "Ali":
    print("Hi, Ali!")
Enter fullscreen mode Exit fullscreen mode

Now let's add a condition that will run if the first condition is False. We'll use the else keyword for this!

password = "hello!"
correct_password = "hi"

if password == correct_password:
    print("Welcome to the website!")
    print("Permission denied")
Enter fullscreen mode Exit fullscreen mode

We can also check multiple conditions using elif:

age = 50

if age > 100:
    print("you are old")
elif age < 20 and age >= 13:
    print("You are a teenager")
elif age < 13:
    print("You are a child")
    print("You are an adult")
Enter fullscreen mode Exit fullscreen mode

Put in different values for age and see what changes!

You can use and to check multiple conditions at once! Or or to check if one things is True or a different thing is True.

Rule of thumb for conditionals: If you want certain code to run sometimes, and other code to run other times: use a conditional!


Loops allow us to run the same block of code over and over again for different values. The most common situation is to loop over a list.

There are two main types of lists -- the first is a for loop. They follow the formula For item in list: do something. The item can be anything -- it's a variable name that changes with each loop.

For example:

dev_employees = ["Ali", "Jess", "Ben", "Peter", "Andy", "Mac", "Liana", "Michael", "Anna", "Mario"]

for employee in dev_employees:
    print("Hi" + employee + "!") # We can join multiple strings together with `+` signs!
Enter fullscreen mode Exit fullscreen mode

At first, employee is Ali, then it moves to Jess, then Ben, etc.

While loops also exist, but they're a bit more rare and have some tricks to them, so we'll skip over them for now!

Rule of thumb for loops: If you want the same code to run over and over again, use a loop!


Quick jargon breakdown before I start explaining functions:

Arguments - passed into a function each time you call (aka invoke) it.

Parameters - the variables in the function definition.

In def myFunction(x, y), x and y are the parameters. When we run that function by saying myFunction(1, 3), 1 and 3 are the arguments.

When I teach functions, I try to teach them in two ways in order to make sense to two different types of thinkers. The first is a reusable chunk of code that you can plug values into to make your code more versatile and allow for less repeated code. In this case, arguments are the "dynamic" pieces of information that are plugged into the chunk of code. So, when you call the function, that value may change. Pretty much a variable that is different each time you run the function.

I also like explaining functions as a series of inputs and outputs -- kind of like a little machine. You put something into the machine and something comes out based on that. The arguments are the things you are feeding into the machine, and the return value is what is outputted. This matches the algebraic definition of functions more closely -- if you remember f(x) = 2x + 1 from school math, those are functions just written on paper instead of written programmatically.

In Python, the order of the arguments being passed into the function corresponds to the order of the parameters in the function declaration. So, if my function declaration looks like def add(x, y) and I then call the function with add(1, 2), in the function 1 will be x and 2 will be y. If I instead ran add(100, 50), x will be 100 and y will be 50. Since x is my first parameter, the first argument I pass into the function will be x, and since y is second, the second value I pass will be y. Sometimes it's helpful to diagram this out.

Anything after the return keyword is the output for the function.

def subtract(x, y):
  return x - y

print(subtract(5, 2)) # 3, 5 is x, 2 is y
print(subtract(200, 50)) # 150, 200 is x, 50 is y
print(subtract(20, 70)) # -50, 20 is x, 70 is y

five = subtract(10, 5)
Enter fullscreen mode Exit fullscreen mode
x y subtract(x, y)
5 2 3
200 50 150
20 70 -50

Another example:

def say_hi(person):
    print("Hi " + person)
    return person

ali = say_hi("Ali")
Enter fullscreen mode Exit fullscreen mode

This function outputs person (which is the same as the input), but it also performs another action -- printing out the person's name with hi. That first action doesn't affect the output -- or what's returned from the function. If you print out ali it's "Ali"!

Rule of thumb for functions: If you want to reuse a chunk of code, potentially with different data, use a function!

Next Steps for Learning how to Code

These are some really important fundamental concepts for programming, but there are so many more! Two important ones are debugging and problem solving.

When you're writing code, the computer is really smart in that it does exactly what it tells you too. But, if you have a typo or any incorrect code, your code is going to throw an error! Learn to work through those errors and love them for telling you what's going on rather than fearing them! They're so helpful!

Problem solving comes in when we try to put the pieces of the puzzle together to make different programs. I'm actually working on a series about that now!

Also, if you want more free resources for learning programming, here's some great ones!

Top comments (28)

arminlinzbauer profile image
Armin Linzbauer • Edited

+1 for the correct use of a comma in "Hello, World!". Far to few people do this correctly.

dwd profile image
Dave Cridland

I always thought it was a Harry Harrison reference.

terabytetiger profile image
Tyler V. (he/him)

This post may seem out of place on a site for programmers, but I wanted to write something from zero.

Honestly, I've been looking for a good article to point beginners to as a way to introduce what programming is. This article will serve that role wonderfully.

Great work! 🎉

esternin profile image

I like your style. One point: "A computer is a machine that processes and stores information" is a rather limited view of what computers are, and is not even true. Strictly speaking, a computer is a device for coherent manipulation of logical levels, but that's just being formal. Note how every one of your examples is about i/o. While I belong to the time when 95% of computing was calculation, you are of the time where 95% of [programming] time is devoted to UI, and computing is all about communication, mostly with the user, but also with the physical world.

Thanks for introducing me to, and a very cool use for it.

karlredman profile image
Karl N. Redman

I appreciate your perspective but I believe you've conflated the various aspects of programming, and furthermore, the functions of a computer.

Computers have three fundamental functions: input, processing, and output. The concept of storage is a bonus.

I think that your statement about computing being all about communication does make sense in the context of modern day application programming Enterprise goals. It's certainly a valid perspective relative to context but it is not the definition as a whole.

ondrejs profile image

Nice article, thanks.
But at one thing I'm a bit confused - you consider Bash as low level language?
b/c I really don't think so (for various reasons). Please explain why, if possible, thank you!

terabytetiger profile image
Tyler V. (he/him)

Instead of asking for a post's author to explain themselves, it's better to outline your reasons for disagreeing so they can respond appropriately.

Your current question is quite open-ended and could be hard for someone to accurately respond to with the clarifications you may be looking for without you presenting your point of view more clearly first.

ondrejs profile image

Yep, understood. Well the main reason is that Bash has very little to do with HW (if something). It does not use pointers, memory management, it does not communicate directly with processor etc. It's a scripting language native for Unix-based systems, nothing more. It's written i C the same way Python is. It's just not as user friendly (for some) as other scripting languages. == My 2 cents.

Thread Thread
karlredman profile image
Karl N. Redman • Edited

Bash is a [x]nix shell language. [x]nix is based (history) on programs that perform 1 task well.... Bash is a shell to your operating system.

With that said, bash as a shell and batch processing language, absolutely has everything you can imagine to do with HW. By virtue of it's purpose you can programmatically control many aspects of your computer system through bash scripts (regardless of programmer friendliness).

While bash is 'only' a scripting language, it's still used on a daily basis more than any other language in the world -by sheer use of scripts over the number of distributions booted each day -often controlling hardware by proxy -most [x]nix computers would never boot without out bash (a hardware controlling perspective).

The purpose of programming is to automate some task (period) -regardless of language. Programming languages are all constraints upon constructs whereupon their only usefulness is to tell computers what to do from human perspectives (note plural perspectives).

Everything has it's purpose in programming. The trick is finding the right tool for the job. Otherwise, it's all the same thing (ones and zeros).

aspittel profile image
Ali Spittel

Good catch -- removed

stecman profile image
Stephen Holdaway • Edited

Where can you see programs in use?

I'd also add to this list any whiteware that sings you a song when it's powered on/finished, microwave ovens, digital cameras, photocopiers, the engine controller in your car (probably the dashboard too if it's a modern car) and any USB device - your mouse and keyboard included.

Once you start working with microcontrollers you realise just how much code is running around us all the time! It's pretty cool/terrifying

swanzer profile image

Thanks Ali. I am a beginner and found this very helpful. I noticed a statement towards the end where there may be a phrasing error, "..the computer is really smart in that it does exactly what it tells you too." Perhaps you meant to say "it does exactly what you tell it to do." Or, since you were speaking about errors in code, maybe you meant it as an example of the computer writing exactly what was typed? That would be clever! Anyway, thanks again. Much appreciated.

caticatt profile image
Alex Ferreira

Great work!

susanjsolomon profile image
Susan Justin Solomon

Up to the mark..simple..Excellent post

aspittel profile image
Ali Spittel

Ah, thank you!!

david_j_eddy profile image
David J Eddy

AS a dev w/ 10+ years professional experience programming...

This one excellent article! Ali, you're crushing it! Well done.

aspittel profile image
Ali Spittel

Thank you so much!

desi profile image

Killing it with the content lately! :D

aspittel profile image
Ali Spittel


andrei3ol profile image

Are you sure about Python in PCL?

edwinrea profile image
Edwin Peña

Excelente post.


Some comments may only be visible to logged-in visitors. Sign in to view all comments.