![]() ![]() If you want to compensate for this, just subtract 2 from the respective value. Note that the number of hosts differs from your version's number, since the network address and broadcast address are also valid host addresses within CIDR. Print('Number of hosts:', ipv4network.num_addresses) Print('Broadcast address:', ipv4network.broadcast_address) """Prints the network address, broadcast address and number Calcualte host IPv6 address range, subnet mask, network, broadcast address. If so, your entire code can be replaced with the usage of the ipaddress module from the standard library: from ipaddress import IPv4Networkĭef print_network_information(ipv4network: IPv4Network) -> None: Calculate all valid subnets, divide a network into subnetworks and network address range, subnet mask, host IP addresses, broadcast address, routing (CIDR). Since you did not tag reinventing-the-wheel, I suppose that you just want to get the job done. ![]() Docstringsīoth of your functions are excellent candidates for docstrings to describe what they are supposed to be doing. The function name ip_information does not convey what it precisely does. You did so with ip_information, why not with to_binary as well? Naming You should use snake_case for function names. I'm just wondering how you see this problem.īinary = ['Īny tips on how to make this better, closer to an advanced (but still, can take under account to make it simple)? Or just a better solution will be definitely on point. In this task I had to create simple IP address / subnet calculator in Python. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |