ThinkDigit Home
Subscribe to the Newsletter
Search
 
SKOAR!       / SHOPPING
 
 
News / Features / Downloads / Channel 5
 
 
Get started with Python
 
Posted by
Nash David
6
523
Posted on: Jul 05, 2011 01:11:18 IST

 
 
 

The first sign that you'd continue pursuing a language is when you get the first words right. In coding parlance, those words are Hello World! I dreaded at the very mention of code – so much of syntax, commands and rules to understand. Moving beyond C and C++, I'd heard a lot about Python, thanks to Google's interest. It's widely believed to be a very powerful language. Surprisingly, however, for someone who's not been in touch with code for years, it comes across as something that's easy to grasp. That's the beauty of a high-level language. It reads just like English.

Thankfully, there's the Hello World program that gets you familiar with the concepts in a particular language. I had the audacity to try out Python yesterday, and for a wonder it all just worked out smoothly! Being a high-level interpreted language, you don't need to compile, rather you need an interpreter. It's actually simple. All you need to do is download Python from its web site.

With Windows, all you need to do is double-click on the installation file. You'd be done in under a minute, quite literally. The next step, is to point the path in Windows, so that python is accepted as a command. I tried version 2.7. After installation, you'll find a folder called Python27 in your C: drive.

In order to map the path in Windows to Python, go to the command prompt (press [Windows] + [R], and type cmd). Type set path=%path%;C:python27 and you're set to use the command python to invoke the Python interpreter.

You need to set the path, so that Windows knows it needs to invoke the Python interpreter when you type "python"

 

Now to start your experience with Python, go to your text editor. Notepad++ or Programmer's Notepad (recommended by Python) is good. Open a new file, and type out the following:

print "Hello World!"

You type in an English sounding line, and that's Python for you

 

Without going any further, save this file, and name it as hello.py. Open the command prompt again and navigate to the location where you saved your first Python script.

Now type python hello.py. If all goes well, you'd see Hello World!

A single line. No more printf or parantheses needed!

Now just to compare the convenience of Python, look at the line of code needed for the same task in C. Excluding comments, you'll have to type the following:

#include<stdio.h>

main()
{

printf("Hello World!");

}

Looking back at your code, doesn't Python truly read like English? It'd be wrong to think this language is named after a reptile. Officially Python claims the name has nothing to do with reptiles. Instead, it's named after a BBC TV show titled, Monty Python Flying Circus.

There's more to Python than Hello World! but as the saying goes, learn to walk before you run, we got to build on the concepts behind a language, before we think of building with it. Hopefully, Python will turn out easier than other languages such as C++.







 
 
 
Latest Features
 
 
 
 
Comments 6comments
 
Posted by Jayant on Jul 23,2011
 
Really, Python is a powerful language but sadly neglected by most of the people. I'm in learning Python and let's see how it goes!
 
Posted by ramesh on Jul 10,2011
 
i look forward for the sequels of these articles!
 
Posted by Nash on Jul 06,2011
 
@Amiraj: Since most of the companies in India directly or indirectly rely on C++, Java, these languages have created more opportunities in the IT industry here. However, this doesn't change the fact that Python is a powerful language and permits quick turnaround in development projects @hellking4u: We plan to cover each aspect going forward so that absolute novices can adapt to it. @student: This question is quite similar to asking whether to choose Windows or Linux; or may be even .NET or PHP for your web application. If you are comfortable with C++ and Java, then working on those skills will help you with better opportunities. However, learning a powerful language such as Python will give you exclusivity.
 
Posted by student on Jul 05,2011
 
should i improve my c++ n java skills? or should i learn Pyhton?
 
Posted by hellking4u on Jul 05,2011
 
Quite surprising that a mention of IDLE is found nowhere in the article....... it's THE best IDE for people beginning in Python!
 
Posted by Amiraj on Jul 05,2011
 
After startidoing a lot of coding in c/c++, embedded c, and java, I started up with python (same reason because of googles interest in it). I did liked it, but after consulting a few people I just was told it's not much used in india, not much of a scope. And being a student, I started making my java skills better. Is it true that theres not much scope for python in india currently?
 
 



 
 

 
 
 
 
Newsletter Subscription
 
 
 
 
 
 
 
 
 
 
 
 
 
 
http://devworks.thinkdigit.com