Table of Contents

Computer Lab 06, Modules and testing

Practical work

Celsius and Fahrenheit

Search the internet and find the conversion equations between the Celsius and Fahrenheit temperature scales.

Module ''temperature.py''

Create module temperature.py with 2 functions:

Specifications:

Test the functions

# file average.py
def average(x,y):
    """Return the average of 2 numbers.
 
    >>> average(10,20)
    15.0
    >>> average(1.5, 2.0)
    1.75
    """
    return (x + y) / 2
 
if __name__ == "__main__":
    import doctest
    doctest.testmod(verbose=True)

Convertor

Still in module temperature.py, create a function convert which shall

Homework