The MagPi Issue 2

Page 24

In issue 1 we showed you how to set up an Oracle VM VirtualBox of the Linux Debian Operating System... Following on from last time, we thought we would show you how to write and run Python programs using your VirtualBox, and a few simple file and folder operations.

Editing And Running Python Programs 1 . Open Leafpad by clicking on the start button and navigate to Accessories > Leafpad.

4. Save the program as 'hello.py'.

5. Open LXTerminal by clicking on the start button and navigate to Accessories > LXTerminal.

2. Let's type a simple Python program into Leafpad: print "Hello"

6. In the LXTerminal type 'ls' and press enter to see the list of files in your Home directory. You can think of the Home directory as being the Linux version of 'My Documents'. You should see a directory called 'Desktop' and also your saved hello.py file. 3. Click File>Save As... from the pulldown menu

NOTE: The Debian LiveCD comes with Python version 2.6.6. You can confirm this at the LXTerminal prompt by typing 'python -V' (Make sure that is a capital V not lower case v).

24


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.