if 5 > 3:
print "good"
elif 3 == 3:
print "hrm"
else:
print "okay..."
for i in 1,2,3,15,6,3,5.4,'blah':
print i
outputs:
1 2 3 15 6 3 5.4 blah
def function():
print "the body of the function"
You do not define what a function returns, this allows functions to return different things for different situations. If a function doesn't explicitly return anything, it returns the special value 'None'.
Python supports a rich set of argument definition and usage:def function(argument="initial value"):means that if the caller of the function does not supply a value for argument, the value "initial value" is automatically inserted.
def function(a, b):then it can be called in two ways with the same results:
function("a value", "b value")
function(b="b value", a="a value")