An Introduction to Python

27Apr07

Python is an object-orientated programming language often used by ‘beginners’: people who are interested in programming, but get mad at seeing a part of code of languages such as C++, C and others.

Note: This article is an introduction to Python. If you already know the basics it’s spoiled time reading this article.

Content:

1. Small history of Python
2. How to get
3. The basics

1. Small History
Because I usually find history of programming languages boring, I will try to keep this part as small as possible. The father of python is the Dutch programmer Guido van Rossum. At this moment (April 2007) version 2.51 is the latest version. If you want to know more about the history you should check it on wikipedia.

2. How to get
Python can be downloaded at: http://www.python.org/. Here you will be able to download the latest version for Windows, Mac and Linux. After downloading, the installer (on windows) will show you the way through to install. For the other two platforms: most people using these are smart enough to install it themselves.

3. The Basics
Over to the real work: Starting to program. After installing you will find in your programs map>python>IDLE (Python Graphical User Interface). Start this.

In this program you can use python commands just to see what they do. I usually ‘test’ my stuff in here. Pretty handy!

Well why don’t you try for yourself? To see a string use ‘print’ (example):

print "hello this is my first python-day"

You will see that under your code ‘hello this is my first python-day’ will pop-up. You just learned your first command! But we are still in this ‘testing-environment’. You probably want to make programs and not only test your code. If you want to make a program go to: file>new window in your IDLE. Now a new window shows up.

Type the same as in the example, but now only in this new window. After that save the file (file>save) as test.py for example. Press F5 and your program will be run in the IDLE, and your text will show up. Easy?

We will go on to variables. Variables are easy to use in long sums, though I will give you an easy example:

a = 5
b = 10
c = a+b
print c

You will see 15 be printed if you execute your program like stated before. Note: after print, I don’t use “c”. This is because I defined c before. In the same way you can use variables for strings. Just check the example:

name = "Ganesh "
friend = "and Sagaro"
both = name + friend
print both

…and yes you will see ‘Ganesh and Sagaro’ pop-up.

The last command you will learn in this introduction is an input command. With raw_input() you will be able to input your own information or store information that you put in into variables. The following example will explain it:

myname = raw_input("Enter your name here. ")
print "hello", myname

In the same way you can store numbers, though you will have to put the command ‘int()‘ (that is for integer) around raw_input() in this way: int(raw_input(“Give me a number that you want to square “)). (try to make that kind of program)

Well, we have come at the end of this introduction to the language Python. Note that this are the very basics of this language and that you will be able to do more when you start progressing. If you are looking for more articles I want you to take a look at the following sites:
http://docs.python.org/tut/tut.html
http://www.ibiblio.org/g2swap/byteofpython/files/120/ (Free book)
http://www.upriss.org.uk/python/PythonCourse.html
– Or just take a look at the programming forum.



8 Responses to “An Introduction to Python”

  1. Whoa ! Python looks really cool dude ! Lemme try it out too !

  2. Hey

    I was surfing the web and i saw this site, pretty cool.
    Currently im running and adult site:Reachton
    k, just want to say hi🙂
    Can i link you from my site? im looking for quality content like yours. If no let me know if i can add u in exchange for a montly fee or something.

  3. Hey

    I was surfing the web and i saw this site, pretty cool.
    Currently im running and adult site:Reachton
    k, just want to say hi🙂
    Can i link you from my site? im looking for quality content like yours. If no let me know if i can add u in exchange for a montly fee or something.

  4. Whoa ! Python looks really cool dude ! Lemme try it out too !

  5. I was surfing the web and it’s pretty coooool

  6. Great information! Very helpful!🙂

    – Moose
    Editor of the Canon T1i Blog


  1. 1 Back to Coding « Sagaro - Weblog of Ganesh APP
  2. 2 Links this week

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: