1from os import system
2print('1. Ping Google')
3print('2. Ping Yahoo')
4print('3. Ping custom URL')
5while True:
6 key = int(input('Input your choice: '))
7 if key == 1:
8 system("ping www.google.com")
9 elif key == 2:
10 system("ping www.yahoo.com")
11 elif key == 3:
12 url = input('Enter URL: ')
13 system("ping " + url)
14 else:
15 print("Invalid Option!")
16
1import subprocess
2
3def main():
4 host = input("Enter Host: ")
5 packet = int(input("\nEnter Packet: "))
6 print("\n")
7 ping = subprocess.getoutput(f"ping -w {packet} {host}")
8 print(ping)
9
10main()
1st = Speedtest()
2 print("Download:=>", st.download())
3 print("upload:=>", st.upload())
4 st.get_servers([])
5 print("Ping :=>", st.results.ping)