Don’t Be Idle With Python

on February 26 | in Homeschooling, Technology | by | with No Comments

IDLE is the one of the best ways to run Python programs. IDLE stands for Integrated Developement Enviroment.  The ‘L’ in IDLE was originally a typo, however it was kept as it makes a more catchy title than IDE!

IDLE has an interactive shell (place) where you type things in at the prompt (>>>) and they are instantly run. You can only experiment with code and commands here. This is mainly known as the Python Shell. If you want to make code that will last and be saved, you a Code Window. To open a code window, select file > new window, and to run select run >  run module. If prompted about saving, click save. The first time you save, it will show a box where you have to enter the name of the program. Then, click ok.

In the Code Window, where you will make your program, you have to save everything changed before you run it. If you want to learn the basics read getting started with Python

Lists ,Tuples, and Maps

Some ways of saving data are lists, tuples, variables, and maps. A list is a collection of items, like this:

>>>a_short_list = ['a', 'short', 'list']

These are variables:

>>>gh = ‘gh’
>>>a = 234

A variable can have a “string”, another variable , or a value inside it. A string is a set of letters inside inverted commas and a value is a number. A variable is like a box containing one thing only.

This is a tuple:

>>>a_short_tuple = (‘a’‘short’, ‘tuple’)

The difference between tuples and lists is that a tuple cannot be changed.

And, here is a map:

>>>opposites_map = {‘you’ : ‘me’
: ‘white’}

What you may be wondering is “why lists and tuples? You could save the same data in lots of variables and it would require less typing.  The reason is that you can change items individually on a list, and save variables (and even other lists!) in different places on it. For example, with our a_short_list, we could change item ‘a’ to ‘two’ using this:

>>>a_short_list[0] ‘two’

And of course, now it doesn’t make sense so change ‘list’ to ‘lists’:

>>>a_short_list[2] ‘lists’

And print (show on the screen):

>>>print (a_short_list)
['two', 'short', 'lists']

Python Modules

To use a module you need to import it using the keyword import. For example, to import Turtle Graphics, type the following:

>>>import turtle
t = turtle.Pen

You should see a window pop up entitled “Python Turtle Graphics” with an arrowhead in the centre. To move the arrowhead, type this:


(in place of “spaces” write the number of pixels you want it to move forward) The “arrowhead” (called the turtle) should move forward the number of pixels you entered in the brackets. Here are the instructions on how to turn:


(instead of “degrees” type in the number of degrees you want it to turn) and it should turn the number of degrees you entered in the brackets.

Word Colour Key:
orange/purple = keywords
purple = printed strings/keywords/values/variables
green = strings

Pin It

Leave a Reply

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=""> <strike> <strong>

« »

Scroll to top