Tuesday, April 21, 2009

Install Python and Say Hello World.

Python is an open source programming language and available free to use.  Python's latest version is Python 3.0.  But for I recommend to start with Python 2.6 as many of the 3rd party libraries are still compatible with Python 2.6 

Python can be freely downloaded from http://python.org/download/ site. Click on the "Python 2.6.2 Windows installer", if you are using Windows OS.  Select other options if you are using a different operating systems.  Download the installer and just follow the simple wizard to install.

Say Hello World!!!

As we are always telling,  if Python can be learned in few days and increases productivity of developers, the basic program also should be simple, right?  
Yes. it is simple and one liner.   Follow the below steps to write your first program of Python.

1. Open Program files --> Python 2.6 --> Python IDLE (Python GUI).
2. You will see a prompt like ">>>"
3. type print "Hello World!!!"  and press enter. 
4. You see the output, "Hello World!!!". 

How can you write as a program? 

1. Open Notepad or any text editor
2. add  the following line to the text file 
      print "Hello World!!!"
3. Save the file as C:\hello.py (Python files are generally saved with .py extension)
4. Open Command Prompt using Start --> Run --> Cmd
5. Change directory to Python folder (in my case c:\python30)
6. Now type the following command at the command prompt
      Python C:\hello.py





That's it you will the "Hello World!!!" output as shown in the above image. :)

We will see how python reads the hello.py file, compiles, etc., in the coming posts.

Saturday, April 18, 2009

Python

Now a days I started learning Python for some project requirement.  I was able to acheive the project's requirement, but I like the language and it's features so thought of continuing learning it. So, lets learn Python.

What    
Python is a simple and powerful high level programming language. 
Officially "Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python's elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms."

Why:
There are many features why python is preferred, Here are few features of Python: Simple, Easy to Learn, Free and Open Source, High-level Language, Portable, Object Oriented, Extensible (Python libraries can be extended by C/C++ programs), Embeddable(Python can be embed with in C/C++ programs), Extensive Libraries...
 
Who:
Python is developed by Guido van Rossum, who is currently working at Google. 
 
Where
Python is often used as a scripting language for web applications and also used for stand alone application development.

When
Python is created in late 80s and the current version of Python is 3.0.  Python 3.0 is released in Dec' 08 after a long time of 2.0 with lot of testing.

References: wikipedia.com and "Byte of Python"