Wednesday, January 6, 2010

Python functions

Here is the example of creating a Python function from todays workshop:
rec1 = [20,2]
rec2 = [24,9]
rec3 = [6,2]

def area(rec):
    area = rec[0] * rec[1]
    print(area)
    return area

area1 = area(rec1)
area2 = area(rec2)
area3 = area(rec3)

print("===")

print(area1)
print(area2)
print(area3)

No comments:

Post a Comment