exercises
+29 · 2 files changed
-
course_1/exercise_1.py+15 −0 -
course_1/exercise_3.py+14 −0
@@ -0,0 +1,15 @@ +#!/usr/bin/env python2 +''' +1. Use the split method to divide the following IPv6 address into groups of 4 +hex digits (i.e. split on the ":") + +FE80:0000:0000:0000:0101:A3EF:EE1E:1719 +''' + +ipv6_address = 'FE80:0000:0000:0000:0101:A3EF:EE1E:1719' +ipv6_address_section = ipv6_address.split(":") + +print '\n' +'IPv6 sections below'+ '\n' +print ipv6_address_section,'\n' + +print "Joined" +'\n\n'+ ":".join(ipv6_address_section) @@ -0,0 +1,14 @@ +#!/usr/bin/env python2 + +''' +Here is an example using this script where I echo an IP address into it and then +the IP address is split into its octets. + +$ echo '192.168.1.1' | ./test3.py +['192', '168', '1', '1\n'] +''' + +import fileinput + +for line in fileinput.input(): + print line.rstrip().split('.')