Python program to determine if the given IPv4 Address is reserved using ipaddress module Last Updated : 10 Jul, 2020 Improve Improve Like Article Like Save Share Report Given a IPv4 Address, the task is to determine whether it is reserved (i.e belongs to class E) or not. What is class E? IP addresses belonging to class E are reserved for experimental and research purposes. IP addresses of class E range from 240.0.0.0 – 255.255.255.254. This class doesn’t have any sub-net mask. The higher-order bits of the first octet of class E is always set to 1111. Examples: Input : 10.0.0.1 Output : Not Reserved Input : 241.0.0.133 Output : Reserved To implement it, we will use the is_reserved method of ipaddress module of Python3.3. # importing ip_address # from ipaddress module from ipaddress import ip_address def reservedIPAddress(IP: str) -> str: return "Reserved" if (ip_address(IP).is_reserved) else "Not Reserved" if __name__ == '__main__' : # Not Reserved print(reservedIPAddress('10.0.0.1')) # Reserved print(reservedIPAddress('241.0.0.133')) Output : Not Reserved Reserved Like Article Suggest improvement Previous Python | URL shortener using tinyurl API Next Python program to determine if the given IP Address is Public or Private using ipaddress module Share your thoughts in the comments Add Your Comment Please Login to comment... Similar Reads Python program to determine if the given IP Address is Public or Private using ipaddress module How to Manipulate IP Addresses in Python using ipaddress Module? Telnet with ipaddress and port in Python Python - Escape reserved characters in Strings List Python program to check if the given string is IPv4 or IPv6 or Invalid Determine a CRS is Projected or Not Using Python OSMnx projection Module Get OSM Features Within a Distance of Address Using OSMnx Feature Module Os Module Vs. Sys Module In Python Determine The Face Tilt Using OpenCV - Python Determine the type of an image in Python using imghdr Like C chirags_30 Follow Article Tags : python-utility Python Python Programs Practice Tags : python