#https://slideplayer.com/slide/4661011/ #https://slideplayer.com/slide/4661011/15/images/14/Classful+Networking+-+%3C1993.jpg ip = "1.0.0.1" ip="192.186.8.2" ip = "10.3.6.7" pr = ip.split(".") p1 = int(pr[0]) p2 = int(pr[1]) p3 = int(pr[2]) p4 = int(pr[3]) ipclass = "IP Error" ne=0 nm=0 nn=0 he=0 hm=0 hn=0 if (p1>=1 and p1<=127): ipclass="A+ (Public)" if (p1==10): ipclass="A- (Private)" subnet = "255.0.0.0" ne=8 nm=2**ne nn=p1 he=24 hm=2**he hn = p2*(256**2) + p3*256 + p4 if (p1>=128 and p1<=191): ipclass="B+ (Public)" if (p1==172 and p2>=16 and p2<=31): ipclass = "B- (Private)" subnet = "255.255.0.0" ne=16 nm=2**ne nn=p1*256 + p2 he=16 hm=2**he hn = p3*256 + p4 if (p1>=192 and p1<=223): ipclass="C+ (Public)" if (p1==192 and p2==168): ipclass = "C- (Private)" subnet = "255.255.255.0" ne=24 nm=2**ne nn=p1*(256**2) + p2*256 + p3 he=8 hm=2**he hn=p4 if (p1>=224 and p1<=239): ipclass="D (Multicast)" if (p1>=240 and p1<=255): ipclass="E (Experimental/Reserved)" print("IP =" + ip ) print("------------") print("IP CLASS=" + ipclass) if (ipclass[0] in "DE" or ipclass==""): exit() print("Subnet Mask=" + subnet) print("Classless Inter-Domain Routing (CIDR)= /" + str(ne)) print("-----------" ) print("Net:") print("exponent=2^" + str(ne) ) print("Number=#" + str(nn) + " of") print("Max=" + str(nm) ) print("-----------" ) print("Host:") print("exponent=2^" + str(he) ) print("Number=#" + str(hn) + " of") print("Max=" + str(hm) ) print("-----------" )
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question