Question
Question 4 Without using any specialised modules, write a Python function to validate an IPv4 address and return the subnet class as a string. An
Question 4
Without using any specialised modules, write a Python function to validate an IPv4 address and return the subnet class as a string.
An IPv4 address is valid if it has 4 decimal numbers separated by a dot with each number being between 0 and 255 inclusive. So the smallest possible IPv4 address would be 0.0.0.0 and the largest would be 255.255.255.255.
If the IP is invalid, return None.
Otherwise, return the class that the IP address belongs to. The classes are as follows:
Example: If the IP is 256.15.8.12 then None would be returned because it is an invalid address. If the IP is 132.78.212.128 then Class B would be returned.
Class End 127.255.255.255 191.255.255.255 223.255.255.255 239.255.255.255 255.255.255.255 Start 0.0.0.0 128.0.0.0 92.0.0.0 224.0.0.0 240.0.0.0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started