lab1-extra

Topics: Python functions

geometric_mean2(a, b)

Implement a function geometric_mean2(a, b) that returns the geometric mean of 2 numbers - i.e. the edge length a square would have to have so that its area equals that of a rectangle with sides a and b. You can use \(\sqrt{a b}\) to compute the geometric mean of \(a\) and \(b\).

Examples:

>>> geometric_mean2(2, 2)
2.0
>>> geometric_mean2(2, 8)
4.0
>>> geometric_mean2(2, 1)
1.4142135623730951

Examples (IPython):

In [ ]: geometric_mean2(2, 2)
Out[ ]: 2.0

In [ ]: geometric_mean2(2, 8)
Out[ ]: 4.0

In [ ]: geometric_mean2(2, 1)
Out[ ]: 1.4142135623730951

Please include the extra tasks in your file lab1.py and submit as Computing lab1 assignment.

Back to lab1.

End of lab1-extra.