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:

Question 4 Without using any specialised modules, write a Python function toExample: 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.0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!