Adding on to the other answers, you can check the OS and decide whether to use "-c" or "-n":
import os, platform
host = "8.8.8.8"
os.system("ping " + ("-n 1 " if platform.system().lower()=="windows" else "-c 1 ") + host)
This will work on Windows, OS X, and Linux
You can also use sys
:
import os, sys
host = "8.8.8.8"
os.system("ping " + ("-n 1 " if sys.platform().lower()=="win32" else "-c 1 ") + host)