Introduction to Python Girls Programming Network School of Information Technologies University of Sydney Mini-Lecture 1
Python Install Running Summary 2 Outline 1 What is Python? 2 Installing Python 3 Running Python 4 Summary
Python Install Running Summary 3 There are many different kinds of programming languages Programming languages taught in schools include: ˆ Visual Basic (and Visual Basic.NET) ˆ C# ˆ Java ˆ Python ˆ ColdFusion To run programs written in some of these languages you will need a program called a compiler. The compiler checks that your program is syntactically correct and then creates an executable version that your computer understands.
Python Install Running Summary 4 We are going to learn Python ˆ Python programs do not need to be compiled - instead they are run by the Python interpreter. http://xkcd.com
Python Install Running Summary 5 Python was developed by Guido van Rossum ˆ started over the Christmas break 1989 ˆ developed in the early 1990s ˆ while Guido was at CWI and CNRI ˆ name from Monty Python s Flying Circus ˆ Guido is known as the Benevolent Dictator for Life (bdfl), meaning that he continues to oversee Python s development. http://www.python.org/~guido/
Python Install Running Summary 6 Python inherits from abc ˆ Guido previously worked on abc at CWI in the early 1980s ˆ abc was designed for beginners and non-professionals ˆ abc placed a high value on clarity: ˆ blocks identified by indentation ˆ minimal use of punctuation ˆ one preferred way of doing things ˆ but lacked extensibility and used idiosyncractic syntax and terminology ˆ Python was designed to appeal to the Unix/C community http://www.python.org/doc/essays/foreword/
Python Install Running Summary 7 So why use Python? ˆ the clean simple syntax is very easy to read and write it has been called executable pseudo-code ˆ it encourages good programming habits ˆ it still has a lot of power and features: objects, exceptions, generators, iterators, threads,... ˆ but these don t get in the way of beginners ˆ and a huge standard library (batteries included): re, os, email, urllib, bsddb ˆ Python scripts are portable to anywhere the interpreter runs ˆ and the interpreter is freely available for: Windows 95-XP/CE, Mac (0S 9-X), any Unix, Amiga, JVM,...
Python Install Running Summary 8 Still not convinced? ˆ Python lets you get on with writing interesting programs ˆ Python programming is fun! [Python is] the most efficient language I ve ever used. It s 10 times better than any of the other tools I have used. It s free, it s object-oriented, it adapts to everything, it runs on everything. There is almost an indescribable, quality without a name attraction on my part Bruce Eckel, author of Thinking in C++, Thinking in Java
Python Install Running Summary 9 Lots of big organisations are using Python Python is everywhere at ilm. It s used to extend the capabilities of our applications, as well as providing the glue between them. Every cg image we create has involved Python somewhere in the process. Philip Peterson, Principal Engineer R&D, Industrial Light & Magic. Python has been an important part of Google since the beginning, and remains so as the system grows and evolves. Today dozens of Google engineers use Python, and we re looking for more people with skills in this language. Peter Norvig, Director of Search Quality, Google.
Python Install Running Summary 10 Download Python from the website ˆ run the Windows installer from http://www.python.org ˆ Python 2.5.2 is the latest version (10.8MB)
Python Install Running Summary 11 Installing Python ˆ if possible install Python as user Administrator ˆ it s best to install it in the default C:\Python25 location
Python Install Running Summary 12 Version confusion! ˆ Don t get Python 2.6a ˆ Don t get Python 3.0 (a.k.a. Python 3000) ˆ Python is changing over the next couple of years ˆ Don t worry, you ll be able to learn the new ways of doing things easily. ˆ Use the current stable version (2.5.2) for now!
Python Install Running Summary 13 Running Python ˆ Under Unix/Linux, just type python at the shell prompt ˆ Under Windows, you can run it from a command shell: ˆ goto Start Run, and enter cmd, and press OK. ˆ then type python
Python Install Running Summary 14 Running the Integrated DeveLopment Environment ˆ idle is an ide for Python written in Python ˆ Under Unix/Linux, just type idle at the shell prompt ˆ Under Windows, goto Start Programs Python2.5 and select IDLE (Python GUI):
Python Install Running Summary 15 Hello World is tiny in Python ˆ Hello World is the canonical first program to write ˆ In Python, Hello World is only one line! ˆ You can type it directly into the Python interpreter: 1 >>> print "hello world" 2 hello world 3 >>> ˆ The colours in this (and all examples) matches the syntax highlighting that idle produces.
Python Install Running Summary 16 Hello World in idle
Python Install Running Summary 17 Writing Python in idle ˆ idle is an ide for Python written in Python ˆ Under Unix/Linux, just type idle at the shell prompt ˆ Under Windows, goto Start Programs Python2.5 and select IDLE (Python GUI):
Python Install Running Summary 18 You should now be able to: ˆ Convince everyone to code in Python :) ˆ Install and run the Python interpreter under Windows ˆ Enter simple statements into the interactive Python Shell