How to Start Programming with Python
July 10, 2011 1 Comment
What is Python?
Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python’s simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed.
Often, programmers fall in love with Python because of the increased productivity it provides. Since there is no compilation step, the edit-test-debug cycle is incredibly fast. Debugging Python programs is easy: a bug or bad input will never cause a segmentation fault. Instead, when the interpreter discovers an error, it raises an exception. When the program doesn’t catch the exception, the interpreter prints a stack trace. A source level debugger allows inspection of local and global variables, evaluation of arbitrary expressions, setting breakpoints, stepping through the code a line at a time, and so on. The debugger is written in Python itself, testifying to Python’s introspective power. On the other hand, often the quickest way to debug a program is to add a few print statements to the source: the fast edit-test-debug cycle makes this simple approach very effective.
How to install Python?
Installing Python is as easy as drinking a coffee. Follow these instructions to install Python
- At first provide a coffee for yourself
- Download the version you like from the official website (Python 2 or 3)
- Run the setup
- Install it the root drive ( for instance C:\Python )
- Start drinking your coffee while it is installing on your computer
- Setup will finish before your coffee finishes
That’s all about Python installation but I myself rather to use it in command line wherever in windos so that I have to add its path to windows variables. To do this open the Advanced System Settings (former System Properties) and add Python path to it like the following picture
How to Write Hello World Application in Python
Python syntax is ridiculously easy to learn. To write your first application in Python you have two options.
First : use Windows Command Line
Second : Use Python Editor (IDLE)
To code within the windows command prompt First Open Command Prompt
Write python and press enter
Python command line will appear and you can start coding. To write first command write
print (“Hello World”) // write print in lower case
and press enter then you will see the result in the next line
To write your application in IDLE you have to open the editor from Start Menu>Python x.x>IDLE
Then again write print (“hello world”) and press enter
As you can see coding in Python is a peace of cake and I strongly recommend you to start programming in Python for your daily usages if you have such a need. It helped me a lot and I learned a lot from its concept in a short time. It worth to try it even once. You can share your experiences with Python or Ruby or other similar tools here.