I l@ve RuBoard Previous Section Next Section

Chapter 4. Functions

In the last chapter, we looked at basic procedural statements in Python. Here, we'll move on to explore a set of additional statements that create functions of our own. In simple terms, functions are a device that groups a bunch of statements, so they can be run more than once in a program. Functions also let us specify parameters, which may differ each time a function's code is run. Table 4.1 summarizes the function-related statements we'll study in this chapter.

Table?.1. Function-Related Statements




myfunc("spam, ham, toast\n")

def, return

def adder(a, b, c=1, *d): return a+b+c+d[0]
def function(): global x, y; x = 'new'

I l@ve RuBoard Previous Section Next Section