Ubuntu makes starting easy, as it comes with a command line version pre-installed. You can begin the process with either the command line version or the graphical Interactive Development Environment (IDLE).
Python Programming From the Command Line
Open a terminal window and type ‘python’ (without the quotes). This opens python in interactive mode.
While this mode is good for initial learning, use a text editor (like Gedit, Vim or Emacs) to write your code. As long as you save it with the .py extension, it can be executed in the terminal window.
To run a script from the command line, type: python my_script.py. To exit the command line, type exit() or hit ctrl+d
Python Programming with IDLE
Can’t imagine writing a long program from the command line? Me either. In that case, you can try IDLE. Open a terminal window and type: ‘idle’. (without the quotes). You’ll see the python graphical shell loaded.
To write a Python script, click on File > New Window. This will open a sort of Notepad type editor. Type in the following code:
#Have user input version and print response
greeting = raw_input(“Jambo”)
print “Hello world in swahili:”, name, ” – Linux rules!”
Couple things going on here. The first 2 lines, preceded by the # sign are just comments.
The third statement uses the input gathered from the raw_input function and assigns it to a variable, greeting. Finally, the print statement will return the result.
Save the file, with a .py extension, then click on Run > Run Module from the menu to run the program.
RUBY ON RAILS
1. Log in and open a terminal if you need to. First we’ll install Ruby 1.8 and Ruby’s development libraries. We’ll also install IRB, which is quite useful while trying Ruby programming.
sudo apt-get install ruby-full
You will be prompted for your password so be sure to get it right!
2. Now that Ruby’s installed, run this example code
$ ruby print ("Mita kuulu!n") ctrl-D Mita kuulu! JAVA $ sudo apt-get install sun-java6-jdk # on Ubuntu 7.10 $ javac HelloWorld.java # filename must match class name $ java HelloWorld # must not write .class here