Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Haithem Ali #96

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
def solution():
import sys
def solution(ip):
ip_splited = ip.split('/')
ip_octets = ip_splited[0].split('.')
ip_octets = [int(i) for i in ip_octets]
octet1 = ip_octets[0]
octet2 = ip_octets[1]
if octet1 == 10:
print("Class A, Designation: Private")
elif 127 > octet1 >= 1:
print("Class A, Designation: Public")
elif octet1 == 127:
print("Class A, Designation: Special")

elif octet1 == 172 and 31 >= octet2 >= 16:
print("Class B, Designation: Private ")
elif 191 >= octet1 >= 128:
print("Class B, Designation: Public")

elif octet1 == 192 and octet2 == 168:
print("Class C, Designation: Private ")
elif 223 >= octet1 >= 192:
print("Class C, Designation: Public")

elif 239 >= octet1 >= 224:
print("Class D, Designation: special")

elif 255 >= octet1 >= 240:
print("Class E, Designation: special")
pass


if __name__ == '__main__':
pass
# taking input from user through command line for example: (python main.py 192.168.1.1/24)
solution(sys.argv[1])
pass