MrSchmid.com

Getting Started with Python

Posted On: Thu, 2007-03-15 15:07 by mrschmid

python tshirt What is Python?

Python is a programming language created by Guido van Rossum and released in 1991. Python is great for small projects as well as larger, more critical uses.

History

Guido van Rossum started the process of creating a new programming language to replace the ABC language in the 1980’s. Python reached python 1.0 status in 1994. Guido started the Computer Programming for Everybody project that aimed for all computer users to have a basic understanding of programming through the use of python. Python has always been under a open license, but due to some legal issues wasn’t considered GNU GPL compliant until 2001. Much of the success of Python as a language is due to the community of developers and the open source model.

Benefits

  1. Open Source – Python is free to use and modify. You have the freedom to use python however you see fit, as long as you release your changes in turn to the community.
  2. Vibrant Community – Python has a vibrant community of devopers, fans and users. Many forums and sites are available to offer support. Countless developers have added features and modules that can make many tasks simpler.
  3. Portable - Your python programs can run in Windows, Mac, Unix, Linux, Palm OS and more with very little effort. Portable refers to the ability to move the program from system to system without drastic rewriting of code, not
  4. Compatible - you can write in python and add it into another program written in another language, such as C. Also known as a glue language.
  5. Sort of Kind of Easy - a big help is that it reads like English, not a bunch of computer code
  6. Interpreted - not forced to compile the program first
  7. Object-oriented
  8. Versatile - can be used for small to very large projects
  9. Named after British comedians Guido van Rossum was inspired by the British comedy group, Monty Python. Read the python documentation and see how many references to Monty Python humor. You'll come across a lot of spam, eggs and the number 42. The logo and mascot has become a little python snake, which is probably for the best as fitting 6 comedian’s faces on an icon would be quite a feat!)

Installation

Go to www.python.org and download the latest stable version windows installer. Find the installer wherever you downloaded it (most likely on the desktop) and run the program. The default settings will be just fine in most situations. You should find the python development environment under programs->Python->IDLE

Modules
We'll also be using livewires and pygame. You'll want to download the pygames for python 2.5

Shell and Idle

Python comes with two major tools to create programs – the Shell and IDLE. The shell is used as a quick notepad to test out small ideas. IDLE is used for creating programs, saving your work, and using most of the features of the development environment. Good programmers use both the shell and the IDLE together. The IDE stands for Integrated Development Environment. Bonus if you can tell me why they might have added the L.

Syntax

Color Coding – IDLE uses color coding to differentiate between different parts of the code. This feature comes in handy as you can see different sections of your code at a glance.

Comments – Comments are preceded by the # symbol

Blank Lines – Blank lines are ignored by the computer, but helpful for keeping order

Print Command – print “string” prints the string to the screen

Wait for User – raw_input(“\n\nPress the enter key to exit.”)

  • Examples
    • Hello World
    • Comments then print “hello world”
  • Exercises
    • Make a program that will print your name, then wait for the user to press enter to exit the program
    • Make a program that displays your favorite quote, and gives the name of the person who said the quote.
( categories: | )

Poll