What is Python?

Python is a general-purpose programming language that is designed to be easy to understand, and simpler than older languages like C++ or Java.

Python is used on this site as a programming language for beginners and is recommended to learn before you get into some of the concepts in Arduino.  Although Arduino's langauge is similar to C, Python's structure will help new programmers learn the main programming concepts faster.

Python, C++ and Java are the 3 programming languages that can be commonly found in universities right now.

Download and Install

For this site,we are using Python 2.7.10 which can be downloaded here:

https://www.python.org/downloads/release/python-2710/

Starting Up Python

Step 1 : Open up IDLE

To begin programming in Python, go to the START menu of and find the Python 2.7 folder.

Python 2.7's IDLE program is the GUI or Graphic User Interface that you need to run.

 

This will open something called Python 2.7.8 Shell.  It will look like the image below:

For the purpose of this course, the Python shell is 2 things:

  1. A place where you can type and execute a single line of code
  2. Your output screen for your program

When you run a program, anything it outputs will show up in the Shell.

Step 2.  Start New File

To open the programming screen, go to File --> New File and you will see the new screen pop up.

The programming window looks like the following.  You know it is the program window because it has the RUN option on it! (I realize this is obvious but it once a student typed their ENTIRE program in the Shell!)

You can type your program in the window and run it.

The shortcut to run your program is hitting F5.  It will always ask you to save the program before you run it.  

Naming Conventions

ALWAYS name your programs after what they do or what they are for.

ONLY use letters and numbers.

NO spaces, periods, dashes or special characters.

On a test, ALWAYS save the program as your first and last name without a space.  Example:  JoeSmith.py

Remember that Python programs end in .py, so do not save it without the ending.

If your program is properly saved as a .py file, it will color parts of your program where it recognizes the commands.

Here are the options you have if you save.  Always pick .py!

This is what it looks like when you have started a new program or saved your program with the .py ending.  Note the colors:

This is what happens if you do not save it with a .py ending.  There no longer is the color checking feature for your program.  Don't do this!