This Python program displays the name of the host machine that is currently running the script.
It uses the socket module to retrieve the hostname.
import socket
# Get and display the hostname
hostname = socket.gethostname()
print("\n--- Host Information ---")
print(f"Current Hostname: {hostname}")
--- Host Information ---
Current Hostname: Shahin-Dev-Machine
- The socket.gethostname() function retrieves the system’s hostname
- The result is printed in a clean format
- This is useful for identifying machines in a network or during remote execution