• No results found

Introduction to Python

N/A
N/A
Protected

Academic year: 2021

Share "Introduction to Python"

Copied!
18
0
0

Loading.... (view fulltext now)

Full text

(1)

Girls’ Programming Network School of Information Technologies

University of Sydney

(2)

Outline

1 What is Python?

2 Installing Python

3 Running Python

(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.

(4)

We are going to learn Python

ˆ Python programs do not need to be compiled - instead they

are run by the Python interpreter.

(5)

Python was developed by Guido van Rossum

ˆ started over the Christmas break 1989

ˆ developed in the early 1990s

ˆ while Guido was atCWI andCNRI

ˆ 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.

(6)

Python inherits from abc

ˆ Guido previously worked on abc atCWI 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

(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:

(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

(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.

(10)

Download Python from the website

ˆ run the Windows installer from http://www.python.org

(11)

Installing Python

ˆ if possible install Python as user Administrator

(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.

(13)

Running Python

ˆ Under Unix/Linux, just typepython 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

(14)

Running the Integrated DeveLopment Environment

ˆ idle is an ide for Python written in Python

ˆ Under Unix/Linux, just typeidle at the shell prompt

ˆ Under Windows, goto Start | Programs | Python2.5

(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

(16)
(17)

Writing Python in idle

ˆ idle is an ide for Python written in Python

ˆ Under Unix/Linux, just typeidle at the shell prompt

ˆ Under Windows, goto Start | Programs | Python2.5

(18)

You should now be able to:

ˆ Convince everyone to code in Python :)

ˆ Install and run the Python interpreter under Windows

References

Related documents

National Image and Competitive Advantage: The Theory and Practice of Place Branding culminates the authors’ research and writing on country of origin effects during the past

In accordance with literature denoting pupil behaviour as anti-structure (see 2.6), individual pupils will have to position themselves amongst peers within the

To clarify whether the nanoscale stress concentration dominated the creep fracture, two types of specimens were prepared: a forward specimen (loading with the column

Our study presents the first series of patient images acquired on the prototype of the next-generation GK-Perfexion with image guidance, characterizing the inter- and

DOMAIN OF TOPIC Any topic to advance knowledge in the field of study Topics that will further the development of professional or industrial practice RESEARCH TYPE An

features of an object) of primitive type are given default values.. int age; // Initialized

Here, I argue that the anxiety concerning practice- based PhDs should not be lightly dismissed because it is a product of the institutional relations practice-based doctorates put

5.2 Appendix 2: Sample Core Scheme Mandate Company Logo In respect of the contract Type of Payment Your bank BIC