Programming for newbies, Part 1: Python

Hi all, this is my first post here at dotTech. There have been many common question when one decides to dive into “world of programming”. These questions includes but not limited to “which language should I learn?” or for those who want a lot of fun, will ask “which language should I learn first?”.

I cannot guarantee you that the answer I’ll provide here is the only and absolute answer, but you if you are going to treat it as starter, then congratulate yourself, you got it right. :)

I came to programming world wondering where I should start. I was having dim knowledge in HTML and almost nothing of CSS. I didn’t know loops except in Microcontrollers/Microelectronics programming which is very low level (and isn’t fun!). So I decided to search for a path.

My first hit was Visual Basic 6. It was such an easy work to make interface (few minutes to be precise) but what useless task it was! GUI without events is really useless! On the VB way, I found a book, but then I didn’t had any VB interpreter/IDE. Buying it from such country as mine, was a tedious job I could not afford, so I dropped it. :(

Not far from there I tried C using the book by the writers of C language itself (Kernighan and Ritchie). To such a newbie as I was, it was convoluted book you don’t want to read! But it did some good stuffs in my brain. It introduced me to loops and like stuffs. After there I dropped whole “dev – geekish” things and dedicated to electronics stuffs (believe me biasing single transistor isn’t fun!). Few years after that I wanted to go back to Dev game seriously. The result of my search will save you some pain of starting from scratch.

WHICH LANGUAGE SHOULD I LEARN?

That depends on what you plan to do with language. If you plan to talk to an English man, you will be sane if you’ll learn English. Same is valid for world of computers. I will do quick review of some languages I have tried. Note that, there are many languages out there; no one language is “the best one”. Rule of thumb is use the “right tool for the right job!”

WANT FUN? PYTHON DOESN’T BITE!

The first language I recommend for beginners is Python. As I quote from their official website:

“Python is a programming language that lets you work more quickly and integrate your systems more effectively. You can learn to use Python and see almost immediate gains in productivity and lower maintenance costs.”

The key to programming, in any language, is discipline and technique. By forcing you to write code in an organized manner via indentations, Python teaches beginners discipline and technique in one go. You work more quickly and create easy-to-read code that is easy to maintain even if you have thousands of lines of code. Although the reasoning behind using Python first may sound like a “baby step”, remember you need to learn how to crawl before you can walk. You will appreciate the discipline and technique Python teaches you when (if) you decide to move onto other languages.

Don’t forget Python interpreter is open source and platform independent so you will find Python on Windows, Mac OS X, and Linux alike. Also Python is self contained in that it comes packaged with its interpreter, Integrated Development Enviroment (IDE) called IDLE, and many standard libraries including ctypes (for accessing C/C++ DLLs), and Tkinter (for creating GUIs).

If you need to add more functionality to your Python, just download and install the third part modules like wxPython for wxWidgets users, pyQT for QT users and so forth.

In most Linux systems, it comes bundled while in Windows (not sure about Mac) you have to manually download and install it. After you get Python, it is very easy to use. To just test its feel, add the Python path to Windows path (I assume you are in Windows). Then at commandline, type “python” without quotes. It will display something like this:

python

To do a test “hello world” program, just type:

print ‘Hello world!’

(Note this is for 2.x not 3.x; it is different in3.x).

Below is the output you should see:

python2

Simple, isn’t it? For writing something more useful, open IDLE, or any editor of your choice (NO MS NOTEPAD!), write your code and save it in .py extension. To run and see results, just open command line and move to the directory and type the following:

the_name_you_gave_the_code_file.py

Although not guaranteed, double clicking the file works also; but the method above is more reliable. If you dont like this long path, grab a different IDE of your choice and start coding! Every IDE offers a something little different than another IDE. For more on Python…continue reading!

PYTHON… IN (MORE) DETAIL

Name: Python (No snakes, from Monty Python circus)

Official Website: www.python.org

Language type: Interpreted

Free Books:

Forums:

Tutorials:

Exclusive IDEs:

An IDE is an “integrated development environment”. In layman’s terms, it is the actual software developers develop in.

Note: Current version of Python (3.x) is NOT backward compatible with previous version (2.x). I recommend use of ver 2.5.4 for those who need very stable version. Version 2.6 is the best choice and is being improved. Version 3.x isn’t very fun due to lack of modules. But keep learning 3.x too because modules are coming out!

>>>Stay tuned for more articles on “Programming for newbies”.

[This article has been contributed to dotTech [.org] by M.D. Stephen with minor edits from Ashraf.]

Related Posts