We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6f8e99d commit 46bab9bCopy full SHA for 46bab9b
Python script to display ip address and host name.py
@@ -0,0 +1,9 @@
1
+## importing socket module
2
+import socket
3
+## getting the hostname by socket.gethostname() method
4
+hostname = socket.gethostname()
5
+## getting the IP address using socket.gethostbyname() method
6
+ip_address = socket.gethostbyname(hostname)
7
+## printing the hostname and ip_address
8
+print(f"Hostname: {hostname}")
9
+print(f"IP Address: {ip_address}")
0 commit comments