Get Started With Python




About: I love inventing and playing around with things. My projects reflect this - usually in-depth reports of problems I have solved as an inventor. I hope that my projects will inspire others to use just a littl-...

Programming is awesome!

It's creative, its fun and and it gives your brain a mental workout. Many of us want to learn about about programming but convince ourselves that we can't. Maybe it has too much math, maybe the jargon thats thrown around scares you. Let me tell you now that that is exactly what ever programmer thought before they became programmers. In fact that's exactly what I though less than 10 weeks ago when I started programming.

Let me tell you right now that anyone can learn to write programs. With advances in easy to read programming languages like python, and the wealth of information on the internet, Its no longer a full time investment to learn the ins and outs of a programming language. Infant most '21st century' programmers are extremely lazy, just learn the basics and build on from there.

This is a No-Jargon, easy to follow ible that you can do right now. Thats right! Minimise facebook and youtube, relax and follow along on your computer.

Old Person Computer

Today we will be looking at a programming language called Python, wikipedia defines python as:

"Python is a widely used general-purpose, high-level programming language. Its design philosophy emphasises code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in languages such as C++ or Java. The language provides constructs intended to enable clear programs on both a small and large scale."

So what does IT ALL MEAN? I thought you said no-jargon? Well basically:

"Python is a compact, general purpose, easy to read programming language. It is very versatile, so can be used to create programs of all shapes sizes."

Why did I pick python? Because the basics of python are easy to pickup and the language has an excellent support community online. After finishing this ible you can start making programs immediately, instead of spending the your time learning the required intricacies of the language.

So lets start!

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: What You Will Need

Firstly you will need a computer with a copy of python, sorry mobile users!

Head over to and download the latest release available with the big yellow button.

Python Download

Then follow the Installer Instructions to install python. Python Installer

To verify python is installed, go to CMD (or terminal) and type:

python --version

Python should respond with the version of python.

Now for this tutorial we will be using an IDE, or Integrated Development Environment (basically a text editor and compiler stuffed together) so head over to and download the "Community Edition" of Pycharm.

PyCharm Community

Then follow the Installer Instructions to install PyCharm.

Now, to start programming!

Step 2: Setup PyCharm and Create a New Project

The first time you launch pycharm it will ask you what keymap and theme you want to use. I would reccomend leaving the key map at default, but you can play around with the theme, colours and fonts to your liking. For this tutorial I am using pycharm community 4.5 with the Dracula theme.

You will then be greeted with a welcome screen.

Press Create New Project

PyCharm Welcome Screen

Select Pure Python then choose a folder to store the files in, then press create ( Note that the folder name will be the name of your project )

PyCharm Project Screen

At this point you should be greeted with the actual Code Creating Screen :P

Code Screen

Step 3: Create Your First Program

Right Click on your project folder and go to new -> Python File

Create New MENU

Name the file and press ok

File Dialogue

Now a new tab will appear in your main area

Below __author__ copy and paste this code.

message = "Hello World"
print message

Then right click on the file and press Run

This will compile our program and return a result. Hello World will be printed in the Run Area

Lets look at what we just wrote.

Step 4: Figuring Out Your First Program

Now lets try to understand what the code

message = "Hello World"
print message

really means.

Firstly I create and set the value of the variable to a string containing Hello World, If you change the text between the speech marks then you can change the value of the variable and therefore the message. For Instance:

message = "Hello Instructables!"
print message


when run.

A string is defined because of the speech marks, strings can also be defined with single marks

message = 'Hello World'
print message

Variables can also have different types. For Instance this:

integer = 29302

is a variable with an integer value ( abbreviated int ) and this:

floatingPoint = 1469.928

is a variable with a floating point value (abbreviated to float).

Basically, the difference between integers and floats is integers are whole numbers while floats are decimal numbers. Integers take up less room but cannot hold decimals. For instance interger 1 / integer 2

integer1 = 1
integer2 = 2
print integer1 / integer2

is 0.5 right? But the result is:

Because integers cannot be divided into decimals. However this:

float1 = 1.0
integer2 = 2
print float1 / integer2

returns 0.5 when run because one of the variables is a float

'Print' simply prints a value. For Instance


prints the string

Print can also print the value of an equation, including combining two strings

string1 = "HELLO "
string2 = "IBLE LOVERS"
print string1 + string2


Step 5: Loops and If's - Control Structures

One of the most essential things about any program is the existence of control structures.

The first control structure is a while loop, this piece of code loops while a condition is true. For Instance this code

count = 0
while count < 10:
    # Add to count
    count = count + 1

    print count 

print "Finished"

runs the code in the loop until count < 10 and then continues on with the program.

The Second is an if-else statement, this piece of code checks and does something if the value of a variable is equal to 10, does something else if the value is equal to 11 and does something else in all other circumstances.

integer = 0

# If its equal to 10
if integer == 10:
    print "ITS 10"

# If its equal to 11
elif integer == 11:
    print "ITS 11"

# In all other Circumstances

print "Finished"

Will return

Because the variable integer is not equal to 10 or 11 and in every other situation it runs else.

To define a while or if control structure put the type (while or if) followed by the true or false value then :

type true == true:

Notice the 'whitespace' for the contents of each loop, python is very specific about whitespace, that's how it knows what code is in a while or if loop. PyCharm uses one tab whitespace which must be consistent across all of your code! You can also adjust the settings to use spaces instead (which has some advantages).

Step 6: Comments

You may have noticed that I have 'commented' on the code I posted on the control structures part. You can comment a piece of code by placing a # and the rest of the line will be commented. When the software is compiled the comments are ignored

# Hello World

Comments are the saviour of code. Because they allow you to show everyone whats in your code and what you were thinking when writing the code. But don't overdo it! Over commented code can be just as bad as under-commented code

So when should I comment my code?

My rule of thumb is to comment your thoughts as your writing, so if you added a variable just to hold your age that serves no other purpose. Comment that.

# Variable that holds my age in years
# Not actually used in this program but # essential for the survival of the human race! myAge = 23</p>

Step 7: Your Finished - Time to Write Something Yourself!

Woah, you just learnt the basics of python!

So "what do I do now?" you might ask, well you can continue to have a play around with your file. When you think you are ready you can take on a challenge. Write a program to add or subtract two user inputted numbers. Use the internet to find out how to get user input then add or subtract the two inputs and be sure to comment your code! While Python is easy to learn it by no means has a low possibility ceiling - programs of all shapes, sizes and configurations are possible using Python and it's comprehensive (and usually community submitted) libraries. Post your code below for suggestions and improvements. Good Luck!



    • Indoor Lighting Contest

      Indoor Lighting Contest
    • Make It Fly Challenge

      Make It Fly Challenge
    • Growing Beyond Earth Maker Contest

      Growing Beyond Earth Maker Contest

    17 Discussions


    13 days ago

    Step 7: Your FinishedWoah, you just learnt the basics of python!
    Step 7: You're FinishedWoah, you just learnt the basics of spelling!


    Question 9 months ago on Step 5

    What is 'whitespace' you are referring here?


    3 years ago

    Hi and tnx for this tutorial. I am using JetBrains PyCharm Educational Edition 1.0 w/ Python 2.7 and 3.4 on my machine. How come when I try to run your 'HelloWorldProgram' I get an 'invalid syntax' error? It only works when I put brackets around 'message'? Am I missing something?

    1 reply

    Reply 1 year ago

    Indeed - I may be a little late - but it's because you are using Python 3.4 as a compiler. Python 3.4 does require brackets (as a slight idiosyncrasy).


    Tip 1 year ago on Step 4

    You do not have to name it string1, string2, etc. but if you do not want to get lost writing long codes, you can also make for example # this and that. the computer ill not read that. I like to see those as post it notes.


    3 years ago

    Thank you for this amazing tutorial!

    1 reply

    Reply 3 years ago

    Thankyou for reading and enjoying this tutorial, as well as dropping a comment :)


    3 years ago

    So there's a question. Why 2.7? Why not 3.5.0 ? I myself using older version, but I've never find good explanation to this question.

    1 reply

    Reply 3 years ago

    I would actually recommend using Python 3.0. But I am currently stuck to using some python 2.7 Libraries and thus I am still using 2.7. When I am finished I will probably make the jump to 3 :P


    3 years ago

    Nice tutorial but the lack of proper syntax in your demo code will turn newbies off


    3 years ago

    Is it possible to make a website like Instructables with python?

    2 replies

    Reply 3 years ago

    Well theoretically yes, but I wouldn't recommend it. I would learn HTML and CSS as that is what instructibles will be coded in. HTML is the 'base' which contains the raw text and data. While the CSS literally just styles it to look nice.

    You could build applets that run within the website to do certain tasks in python. But you would create a website in HTML and CSS ( Or PHP but thats another story ).

    If your interested in learning how to code websites a good places to start is w3schools. It has some good info to get you started :P


    Reply 3 years ago

    I recommend ruby as well. Personally I don't like it (That's another story), but as far as I know it's easier to learn than C# or JAVA and still better than PHP (PHP code can be a mess if You don't know how to keep your code clean). Also there's a lot of good sources about Ruby on the web. HTML and CSS knowledge is required as well.


    Reply 3 years ago

    Post your code so we can all have a look at it, Suggest additions etc :)


    3 years ago

    This was awesome!

    I learned Basic and Pascal in high school in the mid-late 80's.

    This seems SO much easier.

    Thank you!

    1 reply

    Reply 3 years ago

    haha, yeah I have heard the stories of 6000 page books containing every aspect of the syntax for a language :)

    Python is pretty awesome, a lot of fun when you get into it. Nice and easy to code with too :P

    Thanks :)