forked from laith43d/TASK1_IP_CLASSIFIER
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
52 lines (44 loc) · 1.63 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
def solution(ip):
ip2 = ip
x = d = ip3 = 0
for i in range(len(ip)):
if ip[i] == '.':
x = i
ip =int( ip[0:x])
#class A
if ip > 0 and ip < 128 :
for i in range(len(ip2)):
if ip2[i] == "/":
d = int(ip2[i -1 ])
print("IP address class (A)")
if ip == 10 :
print("IP address designation (Private)")
elif ip == 127 and d >= 1 :
print("ip address designation (special)")
else :
print("IP address designation (Public)")
elif ip >= 128 and ip < 191 :
#class B
print("IP address class (B)")
if ip == 172 :
print("IP address designation (Private)")
else :
print("IP address designation (Public)")
elif ip >= 192 and ip < 223 :
#class c
print("IP address class (C)")
h = len(ip2)
if h == 11 or h== 14 :
ip3 = int (ip2[x +1 : x+ 4])
if ip3 == 168:
print("IP address designation (Private)")
else :
print("IP address designation (Public)")
elif ip >= 224 and ip <= 239 :
print("IP address class (D)")
else:
print("IP address class (E)")
break
if __name__ == '__main__':
ip = input("Enter Your Ip Address: ")
solution(ip)