Aug 27, 2010


Python is an interpreted programming language. By just tuping python you can start programming.
When you type,
It willl display as;
here you can type your program.
To exit from it, you can type Crlt+d or quit().

# is used to comment

Interpreter can be used as a calculator.
>>> (25+5)/5

The equal sign in used to assign values to a variable
>>>a=100 # assign 100 to a
>>>b=2*5 # assign 2*5 (10) to b

complplex numbers are also supported, like

In the interactive mode, the last printed output is asigned to the _ variable. So you can use,
>>> _/3 # this work as 150/3
to forword last output to some other task.

Strings in python
>>>word="hello \n world"
>>>print word

If you are deviding the string in to two parts you should use a \ like
>>>word="hello \"
>>>echo word
hello world

String concatination
>>>print word

String repeat
>>>print word*3

String indexing
>>> word='HELP'
Note: The string index is starting from [0].

Some special thing
>>>word[:2] # will give [0]and [1]
>>>word[2:] # will give [2], [3], [4]..

No comments:

Post a Comment

Your comments are always welcome ...