September 2013
Intermediate to advanced
350 pages
9h 38m
English
Writing and Running a Program, explained that in order to save code for later use, you can put it in a file with a .py extension, and it demonstrated how to run that code. Chapter 3, Designing and Using Functions, also included this function definition:
| | >>> def convert_to_celsius(fahrenheit): |
| | ... """ (number) -> float |
| | ... |
| | ... Return the number of Celsius degrees equivalent to fahrenheit degrees. |
| | ... |
| | ... >>> convert_to_celsius(75) |
| | ... 23.88888888888889 |
| | ... """ |
| | ... return (fahrenheit - 32.0) * 5.0 / 9.0 |
| | ... |
Put the function definition for convert_to_celsius from Defining Our Own Functions, in a file called temperature.py. (You can save this ...
Read now
Unlock full access