Python 100 project #9:

As my daily job as a network provider, I need to ask the customer to check their internet speed by visiting I used the third party library to test the


Output Example:

100p $ python3 
the closest server result is as follows
download: 25.30280799925929Mbps
upload: 4.161998302377309Mbps
latency: 4.556ms


Here is the code:

import speedtest

def get_result(id=None):
    servers = []
    if id:

    s = speedtest.Speedtest()

    results_dict = s.results.dict()

    return results_dict['download'], results_dict['upload'], results_dict['ping']

if __name__ == '__main__':

    download, upload, latency = get_result()

    print(f"the closest server result is as follows\n"
          f"download: {download/1000**2}Mbps\n"
          f"upload: {upload/1000**2}Mbps\n"
          f"latency: {latency}ms\n")