This post will describe the exercises and solutions for week three of Kirk Byers Python for Network Engineers. The first exercise of the week is the following:
I. Create an IP address converter (dotted decimal to binary). This will be similar to what we did in class2 except:
A. Make the IP address a command-line argument instead of prompting the user for it.
B. Simplify the script logic by using the flow-control statements that we learned in this class.
C. Zero-pad the digits such that the binary output is always 8-binary digits long. Strip off the leading '0b' characters. For example,
D. Print to standard output using a dotted binary format. For example,
IP address Binary
Note, you might need to use a 'while' loop and a 'break' statement for part C.
break # on some condition (exit the while loop)
Python will execute this loop again and again until the 'break' is encountered.
The first thing we want to do is to import the module