Writing Programs

Open the IDLE application on your computer.  The window that opens will look like a Command Line, Dos or Bash prompt.  It is called the Interactive Prompt.  It allows us to type code and see the response immediately. Click next to the prompt which should look like >>>and type the following line before pressing return.  What happens?

Excellent, the computer has just processed the statement you entered.  Print ( expression )is a built in python function that prints the expression given to the screen. Try entering something like:

One line programs are very rare and we often would like to save the programs we write so we need a slightly better method.  Go to File > New Window – you should now see a blank window.  This is not a python prompt like before but a blank file rather like Windows Notepad or Mac Textpad.   Copy the following code into the window and save it into your programming folder as helloworld.py.

Remember: the lines starting with # are just comments. Now once you have saved this file try clicking on Run > Run Module (or pressing f5) . What happens?

Leave a Reply

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

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