from math import cos,pi
from pyscript import document
def calculate(event=None):
    try:
        phi = int(input("Latitude:"))
    except ValueError:
        document.getElementById("distance").innerText = "Please enter valid numbers."
        return
    R = 6371
    rad = phi*pi/180
    d = pi/180*R*cos(rad)
    document.getElementById("distance").innerText = f"The lenght is {round(d,2)} km"