In [4]:
def foo(val1, val2, val3, calc_sum=True):
    # val{1,2,3} are positional parameters
    # calc_sum is a keyword parameter, and must 
    # follow AFTER positional parameters are defined
    if calc_sum is True:
        return val1 + val2 + val3
    else:
        return (val1 + val2 + val3)/3
In [5]:
foo(1,2,3)
Out[5]:
6
In [6]:
foo(1,2,3, calc_sum=False)
Out[6]:
2.0
In [7]:
foo(1,2,3, calc_sum=True)
Out[7]:
6
In [8]:
foo(1,2,3, False)
Out[8]:
2.0
In [9]:
def bar(val1, val2, val3, mult=1):
    # val{1,2,3} are positional parameters
    # calc_sum is a keyword parameter, and must 
    # follow AFTER positional parameters are defined
    return (val1 + val2 + val3) * mult
In [10]:
bar(1,2,3)
Out[10]:
6
In [11]:
bar(1,2,3, mult=3)
Out[11]:
18
In [12]:
bar(1,2,3,3)
Out[12]:
18
In [13]:
def moo(val1=23, val2=57, val3=42, mult=1):
    return (val1 + val2 + val3) * mult
In [14]:
moo()
Out[14]:
122
In [15]:
moo(val3=76867, mult=10, val2=1, val1=54)
Out[15]:
769220
In [18]:
moo(10, val3=76867, val2=1, mult=54)
Out[18]:
4151412