Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ip_address = input('Введите IP-адреса в формате 10.0.1.1: ')
- parts = ip_address.split(".")
- normal_address = '10.0.1.1'
- for item in parts:
- if parts.isdigit() == False:
- print('Неправильный IP-адрес')
- elif 0 < int(parts) > 255:
- print('Неправильный IP-адрес')
- if len(parts) != 4:
- print('Неправильный IP-адрес')
- elif normal_address.count('.') != ip_address.count('.'):
- print('Неправильный IP-адрес')
- ip_list = ip_address.split(".")
- oct1, oct2, oct3, oct4 = [
- int(ip_list[0]),
- int(ip_list[1]),
- int(ip_list[2]),
- int(ip_list[3]),
- ]
- if oct1 in range(1, 223):
- print('unicast')
- elif oct1 in range(224, 239):
- print('multicast')
- elif ip_address == '255.255.255.255':
- print('local broadcast')
- elif ip_address == '0.0.0.0':
- print('unassigned')
- else:
- print('unused')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement