Traditional Program :D

July 27, 2010 at 1:37 am (Python)

Ok. Lets start with our traditional program, the Hello world program.

The main purpose of IDLE and python terminal is to dynamically check whether the code we entered is correct or not.

In both IDLE and in terminal, you can write the hello world program as

>>>print ‘Hello world’

Hello world

>>>print “Hello world”

Hello world

>>> print “hello ‘w’orld”
hello ‘w’orld

The last line will give you a clear explanation about how the quotations will be treated in python. You can use both single and double quotations which will act independent of each other.

Writing a *.py Program:

As I said earlier, I like to use gedit to type programs. You can use any other editors of your wish, but don’t forget to save the file with “.py” extension. I opened up gedit and I typed the following lines.

#!/usr/bin/python
print ‘Hello World’

I saved the above file as helloworld.py

Now I opened terminal and I typed

devil@devil-laptop:~$ python helloworld.py
Hello world

Yay. I ran the Hello World program 🙂

Isn’t it simple???

Try it =]

Advertisements

Leave a Reply

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: