This post will describe the exercises and solutions for week two of Kirk Byers Python for Network Engineers. This is the first exercise:
I. Create a script that does the following
A. Prompts the user to input an IP network.
1. For simplicity the network is always assumed to be a /24 network
2. The network can be entered in using one of the following three formats 10.88.17.0, 10.88.17., or 10.88.17
B. Regardless of which of the three formats is used, store this IP network as a list in the following format ['10', '88', '17', '0'] i.e. a list with four octets (all strings), the last octet is always zero (a string).
Hint: There is a way you can accomplish this using a list slice.
Hint2: If you can't solve this question with a list slice, then try using the below if statement (note, we haven't discussed if/else conditionals yet; we will talk about them in the next class).
>>>> CODE <<<<
if len(octets) == 3:
elif len(octets) == 4:
octets = '0'
>>>> END <<<<
C. Print the IP network out to the screen.
D. Print a table that looks like the following (columns 20 characters in width):
NETWORK_NUMBER FIRST_OCTET_BINARY FIRST_OCTET_HEX
18.104.22.168 0b1011000 0x58
To get input from an user we need to use the “input()” function. In legacy Python
In the second part of assignments for the first week of Kirk Byers Python for Network Engineers class we will be working with IPv6 addresses. We start with the following IPv6 address: FE80:0000:0000:0000:0101:A3EF:EE1E:1719. The goal is then to split this
I’m not known for going on rants but lately I’ve been seeing a lot of stupid tweets from vendors that have really bothered me. So today I’ll give my best Tom Hollingsworth “networkingnerd” impression and tell you what’s on my
This post is the first one going through the Kirk Byers Python for Network Engineers class. In the first class Kirk shows how to pipe data into Python by using the module fileinput with the following code(modified for Python3):
for line in fileinput.input():
As you have seen lately on the blog I’ve been fiddling around in Python. One of the best resources out there to learn Python for Network Engineers is the free e-mail course by Kirk Byers. Kirk is a CCIE emeritus
In my previous post on Argparse I had some issues with validating values and printing help output for values that are out of range. I got some great suggestions from my smart colleagues Mikkel Troest and Patrick Ogenstad who are
I’m learning the basics of Python and these are my publically available notes for my reference. Hopefully they are useful for my readers as well. The For loop in Python is used to iterate through different objects such as lists
This post was written to help CCDE candidates get into the right mindset but is very applicable to network architects and network engineers in general. We humans tend to have a lot of bias. Sometimes it’s based on experience but
I’m fiddling around a bit with Python. I’m planning to write a little script that pings a host or hosts and logs it to a file. Should be pretty basic but it’s good practice for me to take user input,
Happy new year to all the readers of the blog! I’ve been lacking the time to update the blog lately which I’m sorry for. Work is keeping me busy with some interesting projects. I hope to get a bit more