Jun 5
piccole modifiche
meh, mi ero reso conto che i blocchi di codice si confondevano abbastanza con il resto dei post, per cui ho customizzato leggermente il css, con questa roba:
pre.wp-block-code {
	
	    border-left: 6px solid #5de8ff;
  background-color: #F5F7F9;
    padding: 5px;
	color: black;
}…da migliorare eh!
forse ĂƒÂ¨ un bene darsi dei tempi.
ieri non ci stavo capendo un cazzo con python e gli esercizi. oggi l’esercizio 5 l’ho fatto in 2 minuti:
5. You have the following three variables from the arp table of a router:
mac1 = "Internet  10.220.88.29           94   5254.abbe.5b7b  ARPA   FastEthernet4"
mac2 = "Internet  10.220.88.30            3   5254.ab71.e119  ARPA   FastEthernet4"
mac3 = "Internet  10.220.88.32          231   5254.abc7.26aa  ARPA   FastEthernet4"
Process these ARP entries and print out a table of "IP ADDR" to "MAC ADDRESS" mappings. The output should look like following:
             IP ADDR          MAC ADDRESS
-------------------- --------------------
        10.220.88.29       5254.abbe.5b7b
        10.220.88.30       5254.ab71.e119
        10.220.88.32       5254.abc7.26aa
Two columns, 20 characters wide, data right aligned, a header column.svolgimento:
#!/usr/bin/python3
mac1 = "Internet  10.220.88.29           94   5254.abbe.5b7b  ARPA   FastEthernet4"
mac2 = "Internet  10.220.88.30            3   5254.ab71.e119  ARPA   FastEthernet4"
mac3 = "Internet  10.220.88.32          231   5254.abc7.26aa  ARPA   FastEthernet4"
print("{:>20}{:>20}".format("IP ADDR", "MAC ADDRESS"))
print("-" * 40)
print("{:>20}{:>20}".format(mac1.split()[1],mac1.split()[3]))
print("{:>20}{:>20}".format(mac2.split()[1],mac2.split()[3]))
print("{:>20}{:>20}".format(mac3.split()[1],mac3.split()[3]))
risultato:
[sugo@vm pynet-learning-python]$ ./exercise5.py
             IP ADDR         MAC ADDRESS
----------------------------------------
        10.220.88.29      5254.abbe.5b7b
        10.220.88.30      5254.ab71.e119
        10.220.88.32      5254.abc7.26aa
direi che va bene no? đŸ™‚
No commentsNo Comments
Leave a comment