Skip to content

Commit 46bab9b

Browse files
authoredOct 4, 2022
Create python script to display ip address
Python script to display ip address and host name. Please add hacktoberfest tags.
1 parent 6f8e99d commit 46bab9b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)
Please sign in to comment.