Python Lists, Strings, and Other Data Sequences 111
The following listing shows the shell command that starts the Python
interpreter with file tconvctfl.py and the results.
$ python tconvctfl.py
Values of temperature in Celsius:
[5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]
Values of temperature in Fahrenheit:
[41.0, 50.0, 59.0, 68.0, 77.0, 86.0, 95.0, 104.0, 113.0,
122.0, 131.0, 140.0, 149.0, 158.0, 167.0]
7.3.3 Implementati on Using a Function
Listing 7.5 shows a Python script that solves the same problem as the previous
script. It defines function tconvf in lines 9–16. This function takes a list of
values of temperature in Celsius, computes the temper ature in Fahrenheit,
and retur ns these values in a new list. This Python script cr