Tutorial:Jython/1 Introduction

From HandWiki

Python Tutorial

This tutorial is fully interactive and it is powered by Java. Please select Always trust content from this publisher when you will see a pop-up window. Please wait while the Java downloading the library for this tutorial. If Java is not installed, you still can see the examples, but they will be interactive.

About

This Python tutorial is designed for beginners. It can help you to get started with this powerful scripting language. Unlike many other tutorials, it is fully interactive since you can explore the Python and see the outputs of the code snippets directly in your browser.

This tutorial is a first step towards the DataMelt programming environment which extends Python and integrates it with hundreds of Java library classes and methods for all occasions. This puts unprecedented power in the hands of users, far beyond the C++ implementation of Python. Later we will learn how to use numerous numeric and graphic libraries for almost any scientific and technical field.

Getting started

Each section of this tutorial has code examples integrated into two windows. Left window is a code editor which can be used to type Python commands. Press the [Run] button on the right to run these commands and to see the output. You can change vertical divider position with the mouse if the output does not fit to the right window.

Let's get familiar with the interactive prompt. Type:

<jc lang="python"> print 'ok' </jc>

and press [Run]. You will see "ok". This means that you can talk to the interactive Python. In fact, now you have learned how to print a string (“ok”). You can type the same a new text in the editor, and press [Run]. For example, let's print ok on different lines using "\n" as a separator:

<jc lang="python"> print 'ok\nok\nok' # comment </jc> where "#" indicates your comment for this code. Again, press [Run]. You will see a pop-up window with the 3 lines of "ok". The reason why you got a pop-up window instead inline output, is because the text did not fit to the on-line window. You can type several commands on one line, but separated them with ";"

<jc lang="python"> print 'ok'; print 'ok'; print 'ok'; # comment </jc>

In some cases you can edit example and run the modified code. In such cases you will see a green border around such codes. Try to change 'ok' to something else and print "output"

<jc lang="python_edit"> print 'ok' # you can edit this command </jc>

If you are not the registered member, you cannot run the code and cannot see the outputs.

Standalone application

You can download the standalone application to work with Python code snippets from this tutorial. Look at JythonTutorial:Download section.