Download
14 lines 386 BPythonModified 2020-08-20 raw
1234567891011121314
#!/usr/bin/env python3
import sys, os, math

print("Python v"+sys.version)
if 'GET_n' not in os.environ:
    print("Add a query string for '?n=...' to this URL to get a square root.")
else:
    n = os.environ['GET_n']
    try:
        n = float(n)
    except:
        print(f"This is not a valid number: {n}")
    else:
        print(f"The square root of {n} is {math.sqrt(float(n))}")