How to write your first ‘Hello World!’ Program in Python 2.7.3/3.2

Beginners tutorial in Python 2.7.3/3.2

Many people see Python as either a complex, impossible to learn language somewhere in the learning range of…never, or a beginners language not suited to be used as a real language.
Well, I see it differently. Quite differently.
Python is a great cross-platform language that is quite easy to learn and begin with, but also a quite in-depth and powerful language, used all over the place in major corporations such as NASA, Google, Yahoo, and many, many more (larger list here.)
It is used in game programming, such as Civilization 4, but also on the more serious side of things with Google-run-YouTube, Yahoo Maps, Disney uses it in their animations, even the CIA uses it in low-level coding for their website!

Anyways, enough info on why Python is so great. This is a tutorial, not history class.

To start off, you need Python. Any OS works, on Linux and Mac it comes pre-installed, but it may require updating. Windows does not come pre-installed with it, so you will have to install it. However, it is quite easy to do all-of-the-above.
Simply go to http://www.python.org/getit/ to getit. Go through the steps to install/update python, they should be relatively simple and easy, regardless of OS. You should now have either Python 2.7.x or Python 3.x, either works.

Once you complete the install/upgrade we can begin coding (Yay!)

OK, now open up Python. It may be something along the lines of IDLE, that’s the IntegratedDevelopmentEnvironment. It is different on every computer, so you will have to figure out how to on your own system. Hopefully you have IDLE installed, as that will make it a LOT easier. Once IDLE has started go to

File > New Window Ctrl/Cmd + N

A new window should appear, if not attempt to open a new window by pressing Ctrl/Cmd + N.
When the new, blank – it should be a blank window – window opens is when it finally changes a little bit between Python 2.7.x and Python 3.x
In Python 2.7.x you just type:

print 'Hello World!'

Whereas in Python 3.x you would have to add parenthesis – () – around the ‘Hello World!’ part:

print ('Hello World!')

That’s all there is to it!

As you can see, Python is not the freakishly hard language some people make it out to be, but neither is it something only a kid would use in his tinkering around. It is a well balanced language, good for beginners and experienced alike.

Advertisements
Tagged , ,

Tell us what you thought!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: