Learning Python

They Article is a quick Python Learning guide so hang onto your seat belts and ride along !!
PYTHON

In Linux type python and it will start python.

>>> is the python prompt

>>> print 1+1
 2
>>> print 1*3
 3
 >>> print 2**16
 65536
>>>print "HeloWorld"
 HeloWorld
>>>print "HeloWorld\n"
 HeloWorld

The above will give extra line beneath the program.

>>>Print "Helo\tWorld\n\n"
 \t = seperate by 8 chracters so the result is

Helo        World

>>>print 'Helo World'
 to Exit Python Ctrl + D
>>>help
 help>keywords <--

Variables:

name = "Hyp3ri0n"
 >>>print name
 Hyp3ri0n

nano heloworld.py

First check which python

#which python <--

if the Linux prompt says /usr/bin/python then type the below line to setup the environment

#!/usr/bin/python
#Author Hyp3ri0n Date 23-09-2011
 #Purpose Helo world python
print "HeloWorld"
#END
root# python heloworld.py
and it will run
 make chmod 777

./heloworld.py and it will run

Using Variables in the program

so in the heloworld.py type

message = "Helo World !"
 print message
#END
./heloworld.py <--


Thanks,
Salman Aftab