Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribedExample: 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions