Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. ip_address = input('Введите IP-адреса в формате 10.0.1.1: ')
  2.  
  3. parts = ip_address.split(".")
  4. normal_address = '10.0.1.1'
  5.  
  6. for item in parts:
  7. if parts.isdigit() == False:
  8. print('Неправильный IP-адрес')
  9. elif 0 < int(parts) > 255:
  10. print('Неправильный IP-адрес')
  11. if len(parts) != 4:
  12. print('Неправильный IP-адрес')
  13. elif normal_address.count('.') != ip_address.count('.'):
  14. print('Неправильный IP-адрес')
  15. ip_list = ip_address.split(".")
  16. oct1, oct2, oct3, oct4 = [
  17. int(ip_list[0]),
  18. int(ip_list[1]),
  19. int(ip_list[2]),
  20. int(ip_list[3]),
  21. ]
  22. if oct1 in range(1, 223):
  23. print('unicast')
  24. elif oct1 in range(224, 239):
  25. print('multicast')
  26. elif ip_address == '255.255.255.255':
  27. print('local broadcast')
  28. elif ip_address == '0.0.0.0':
  29. print('unassigned')
  30. else:
  31. print('unused')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement