Python
Python
Python
Henning Schulzrinne
Department of Computer Science
Columbia University
(based on tutorial by Guido van Rossum)
>>> fib(2000)
>>> ask_ok('Really?')
Oct 1, 2023 Advanced Programming
Spring 2002
Keyword arguments
last arguments can be given as keywords
def parrot(voltage, state='a stiff', action='voom',
type='Norwegian blue'):
print "-- This parrot wouldn't", action,
print "if you put", voltage, "Volts through it."
print "Lovely plumage, the ", type
print "-- It's", state, "!"
parrot(1000)
parrot(action='VOOOM', voltage=100000)
f = make_incrementor(42)
f(0)
f(1)
john = Employee()
john.name = 'John Doe'
john.dept = 'CS'
john.salary = 1000