4. python functions

Post on 30-Jun-2015

90 Views

Category:

Education

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

Week 2

TRANSCRIPT

Functions

colon

start with ‘def’function name arguments

def twotimes(n):

return 2*n

‘return’ precedes

the value to be sent backNo declaration of types

of function or arguments

New definition?

New definition?

New definition?

Popquiz!

What happens now?

Popquiz!

What happens now?

No ‘overloading’

More

functions

What does this mean?

Functions can be arguments

Functions can be arguments

We can also use an “anonymous function”

Using

parameters

Why Python?

• Easy to learn syntax

• Built-in datatypes for lists, strings etc.

• Runs on many types of machines

• Many scientific librartes (SciPy, NumPy)

• Large community of scientists using it

• #1 programming language in universities

• Shell mode for experimentation

Why Python?

• Easy to learn syntax

• Built-in datatypes for lists, strings etc.

• Runs on many types of machines

• Many scientific librartes (SciPy, NumPy)

• Large community of scientists using it

• #1 programming language in universities

• Shell mode for experimentation

• Awesome Excel integration

top related