Difference between revisions of "Python1"

From SourceWiki
Jump to navigation Jump to search
Line 28: Line 28:
 
=Python as a Calculator=
 
=Python as a Calculator=
  
Let's try a few commands out:
+
Let's try a few commands out.  If you type:
 +
 
 +
<source lang="python">
 +
>>> print "Hello!"
 +
</source>
 +
 
 +
you'll get:
 +
 
 +
<pre>
 +
Hello!
 +
</pre>
 +
 
 +
If you try:
 +
 
 +
<source lang="python">
 +
>>> print 5 + 9
 +
</source>
 +
 
 +
you'll get:
 +
 
 +
<pre>
 +
14
 +
</pre>
 +
 
 +
=Getting Help=
 +
 
 +
Python has lots of useful documentation.  For example, take a look at: http://docs.python.org/.

Revision as of 14:32, 2 October 2012

Python for Scientists

Introduction

http://xkcd.com/353/

Getting Started on BlueCrystal Phase-2

After you have logged in, type the following at the command line:

module add languages/python-2.7.2.0
python

This should start up an interactive python session:

Python 2.7.2 (default, Aug 25 2011, 10:51:03) 
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

where we can type commands at the >>> prompt.

Python as a Calculator

Let's try a few commands out. If you type:

>>> print "Hello!"

you'll get:

Hello!

If you try:

>>> print 5 + 9

you'll get:

14

Getting Help

Python has lots of useful documentation. For example, take a look at: http://docs.python.org/.