If your program performs a task more than once, you can define this task as a separate chunk of code. This chunk of code is known as a function.
Here is a simple example of a function and how to use it:
# convert a patient temperature from Fahrenheit to Celsius def FtoC(degf): degc = (degf - 32) / 1.8 return degc tempF = 50.0 tempC = FtoC(tempF)
The following sections provide more details on how to define and use functions: