<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nishant Gour</title>
    <description>The latest articles on DEV Community by Nishant Gour (@nishantgour).</description>
    <link>https://dev.to/nishantgour</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F631605%2F6dc1c5f6-4425-4d2f-9938-8be91e094eb1.jpeg</url>
      <title>DEV Community: Nishant Gour</title>
      <link>https://dev.to/nishantgour</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nishantgour"/>
    <language>en</language>
    <item>
      <title>Display Hostname and IP address using Python</title>
      <dc:creator>Nishant Gour</dc:creator>
      <pubDate>Wed, 26 May 2021 08:49:36 +0000</pubDate>
      <link>https://dev.to/nishantgour/display-hostname-and-ip-address-using-python-5hng</link>
      <guid>https://dev.to/nishantgour/display-hostname-and-ip-address-using-python-5hng</guid>
      <description>&lt;p&gt;In this article, We are going to see how to Display the hostname and the IP address with the help of the language Python.&lt;/p&gt;

&lt;p&gt;As we all know about IP, IP (Internet Protocol) is a fundamental networking concept that provides address assignation capability in a network. &lt;/p&gt;

&lt;p&gt;How we are going to do it?.  so we will be using the socket module of python&lt;/p&gt;

&lt;p&gt;Python provides gethostname(),gethostbyname() two function.&lt;br&gt;
gethostname() retrives the standard host name for the local machine. gethostbyname() retrives host information corresponding to a host name from a host database.&lt;/p&gt;

&lt;p&gt;Code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import socket
hostname = socket.gethostname()
ip_address = socket.gethostbyname(hostname)
print(f"Hostname: {hostname}")
print(f"IP Address: {ip_address}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;let's discuss the above 5 lines of code..&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In our first line, we have imported our socket module.&lt;/li&gt;
&lt;li&gt;in second-line we are getting the hostname by socket.gethostname() method.&lt;/li&gt;
&lt;li&gt;The third line we retrives host information corresponding to a hostname from a host database.&lt;/li&gt;
&lt;li&gt;and then the last two lines are for printing them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So this is a short and sweet article for all of you!&lt;/p&gt;

&lt;p&gt;I hope you liked it!. Let's catch up in the next articles. &lt;/p&gt;

&lt;p&gt;original published on : &lt;a href="https://codingnuts.tech/"&gt;https://codingnuts.tech/&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you liked it, Please &lt;strong&gt;Support Me&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://www.buymeacoffee.com/nishantgour"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XZmDDNkD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://img.buymeacoffee.com/button-api/%3Ftext%3DBuy%2520me%2520a%2520coffee%26emoji%3D%26slug%3Dnishantgour%26button_colour%3DFFDD00%26font_colour%3D000000%26font_family%3DCookie%26outline_colour%3D000000%26coffee_colour%3Dffffff"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
