Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
IP Network and Broadcast calculator
#!/usr/bin/env python3.3 # -*- coding: utf-8 -*- # # IP.py def result(arg): out='' cpy=arg for i in range(3): out='.'+str(cpy&0xFF)+out cpy>>=8 return str(cpy&0xFF)+out binIP=0 IP=input("Give me IPv4: ") temp=0 dots=0 for i in range(len(IP)): try: temp=temp*10+int(IP[i]) except ValueError: binIP<<=8 binIP|=temp temp=0 if dots==3: bin_mask=0xFFFFFFFF>>int(IP[i+1:]) break dots+=1 print() print("Network :", result(binIP&~bin_mask)) print("Broadcast:", result(binIP|bin_mask))
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
jsa
(P2) Ciągi 2
sainik
kill
lambda list map
ConstructorBehaviourInInheritance
My Personal data
3564
rstring
EJ_2_python_20.068.214-9_20.116.927-5
Please log in to post a comment.