Upload
in4400
View
95
Download
1
Embed Size (px)
DESCRIPTION
Week 2
Citation preview
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