Wednesday, September 16, 2009

Python : -" Hello World "

Befor you start learning PYTHON you will have to have python software. This software can be downloaded from follwing link:

http://wiki.python.org/moin/BeginnersGuide/Download.

you should download the relevent packege according to your operating system.

Install it .


now Let's how can we write out first programme.

1.
we can do it with using Phython shell.

click on START button then ALL PROGRAMS then PYTHON2.6 then select IDLE(python GUI).

white screen consol will be appeared .

type on there as follows;

When you type like that Hello World will be printed there ,itself.



print " Hello World"


Hello World


2.
we can do it using python command line.

click on START button then ALL PROGRAMS then PYTHON2.6 then select PYTHON(Command Line).

Then black colour consol will be appeared ;

you can type it as above example and or as follows.

print "Hello World " * 3


Hello World Hello World Hello World


rem : when you are multipling by 3 . there should be a gap either side of "*";

3.

you can try this out with the operating systems's consol application.
if it is Windows -MS Dos.
Ubuntu -Ubuntu Konsole.
Kubuntu -Kubuntu Konsole.

Befor you use that you need to configure the path .

path is like a specfic preticular place where python's file saved.you can make it as like Java path.

Then go to cmd prompt. And change to your "python 26" dirctory .

And Then type on the consol like python.look follows.

fisr appear as :-

c:\Python26>

then type "python"

c:\Python26> python

After that you can print what ever thing you want . same as we did in the above examples.

print"I am a technology Geek"


I am a technology Geek



4.We can do codings stuff using a text editor.
type on your editor as

print "Lahiru" * 3

then save it as .py extension..

like this lahiru.py

make a folder inside python26 folder and save it inside that.

let's say your folder name is PythonProjects.

Then go to the consol application and go your project sved place.
like this

c:\Python26\PythonProjects>_

go to above place and type the python an filename with the extension.as follows.

c:\Python26\PythonProjects>python lahiru.py

Then out put will be :


Lahiru Lahiru Lahiru



Imp:-

If you want to go out from the pythons Server to your friendly Editor use Ctrl+Z


No comments:

Post a Comment