Printing your machine's name and IPv4 address
Sometimes, you need to quickly discover some information about your machine, for example, the hostname, IP address, number of network interfaces, and so on. This is very easy to achieve using Python scripts.
Getting ready
You need to install Python on your machine before you start coding. Python comes preinstalled in most of the Linux distributions. For Microsoft Windows operating systems, you can download binaries from the Python website: http://www.python.org/download/.
Currently, Python 3.x is released in addition to Python 2.x. Many of the current Linux distributions and macOS versions are still shipping Python 2 by default. However, some ship both of them.
Download the relevant installer for your operating system and the relevant version based on whether your operating system is 32 bit or 64 bit.
You may consult the documentation of your operating system to check and review your Python setup. After installing Python on your machine, you can try...