1. Home
  2. Computing & Technology
  3. Python

"Merry Christmas!": A Quick Tour of Python

From Al Lukaszewski, for About.com

4 of 7

Defining Functions

Now, we can make a function which calls the last method of the class:

def prints(string):
string.printme()
return

Next, we define two more functions. These illustrate how to pass arguments to and how to receive output from functions. The strings in parentheses are arguments on which the function depends. The value returned is signified in the 'return' statement at the end.

def caps(word):
value = string.capitalize(word)
return value

The first of these functions takes an argument word. It capitalises it via string.capitalize() and returns it as value.

Explore Python
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Python

©2009 About.com, a part of The New York Times Company.

All rights reserved.