Learn to Code in 10 Minutes!

It's pretty much a universally agreed upon fact: the ability to make computer programs is one of the most valuable skills to have in the 21st century. However, most people also assume that learning to code is an impossible task that takes years of training and a mastery of everything from mathematics to quantum physics. While the top paid programmers and software engineers do indeed have years of experience and a strong mathematical background, that doesn't mean coding itself is inaccessible to most people. In fact, by the end of this blog, I'll have shown you how to make a basic computer program (using the Python language), and I'll point you to resources to help you continue learning.

Step One: Get the necessary tools.

Before I explain what programming is and how it works, let's download and set up everything we need. We are going to be using Python, a programming language especially suited towards beginners, due to its very easy-to-understand syntax. Jump to the section below related to your computer's operating system:

For Unix-based systems (Mac, Linux)

You're in luck! Python comes pre installed on Mac OS and most Linux distributions. But, we want to make sure we have the latest version, so let's download it anyway. You can do this by going to http://www.python.org/download/ and choosing the right version of Python 2 for your computer. Download and install it, and now you should have IDLE (the official Python development environment) on your computer. When you open up IDLE, you'll see a blank window where you can enter text.

For Windows

Python does not come standard on Windows, but setup is still painless. Choose the correct version of Python 2 for your computer. Run the installer once you download it, and you'll now have IDLE (the official Python development environment) on your PC. You can confirm this by searching for IDLE and opening it. You should see a blank window where you can enter text.

Step Two: How does all of this work?

Now for some technical details. Don't skip this part! Technically, computers only understand two things. 0 to turn some component off, and 1 to turn it on. Thankfully, computer programming languages allow us to tell the computer to do things without dealing directly with transistors and other hardware. That's why I can tell the computer this: print("Hello, world") and it understands what I mean. The language's compiler acts as a translator that turns print("Hello, world") into a long string of 1's and 0's for the PC to understand. Now, not all languages are compiled (Python, for example, is interpreted: another program takes care of reading your code and executing it, rather than the computer itself), but that's the basic idea behind programming. That's why every language has a strict set of rules for syntax. 

Step Three: Your first program!

Open up IDLE and type this (numbers to the left represent line numbers): 

1    //This is a comment! Here you can write notes that the computer will ignore.

2    i = 0 //Here we are creating an integer called "i" and setting its value to 0. 

3    while i < 5: //This is a while loop. It executes a statement as long as a certain condition is true.

4        print "This is a statement!" //We are telling the computer to display the words contained in the quotes

5        i += 1 //Increment i by 1 each time until i = 5 and the loop exits


Save your program as myfirstprogram.py and run it! You should see this output:

This is a statement!

This is a statement!

This is a statement!

This is a statement!

This is a statement!

Step Four: What's next?

Congrats on making your first program! If you couldn't get it to work, that's okay. Regardless, you probably want to know more at this point, so here's where I'll point you to some resources for Python and programming in general. Remember, Rochester offers many programming courses for both computer science and non-computer science majors, one of which is CSC 161 (a Python course), and there are countless tutorials for everything from making games to building websites to programming processors and graphics cards. Try these links and play around: 



Happy coding!


About the author

Ty Kelley

One Comment

Leave a comment
  • Hey Ty,

    Thank you for a valuable post on how to learn Python in short time. Your suggestions & links are really good starting points, I think. I have myself used mainly C++ and R languages. However, I see that Python is really flexible and, thus, increasing in popularity. Therefore, I am to learn more and more about Python and how I can use it in Psychology.
    Again, thanks.

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.