All tasks and additional files can be downloaded from repository.


Starting from section “4. Data types in Python” there are automated tests for testing tasks. They help to check whether everything matches the task, and also give feedback on what does not correspond to the task. As a rule, after the first period of adaptation to tests, it becomes easier to do tasks with tests. Testing is done using the pyneng utility. Learn more about how to work with the pyneng utility.

Task 12.1#

Create a ping_ip_addresses function that checks if IP addresses are pingable.

The function expects a list of IP addresses as an argument.

The function must return a tuple with two lists:

  • list of available IP addresses

  • list of unavailable IP addresses

To check the availability of an IP address, use the ping command.

Restriction: All tasks must be done using the topics covered in this and previous chapters.

Task 12.2#

The ping_ip_addresses function from task 12.1 only accepts a list of addresses, but it would be convenient to be able to specify addresses using a range, for example

In this task, you need to create a function convert_ranges_to_ip_list that converts a list of IP addresses in different formats into a list where each IP address is listed separately.

The function expects as an argument a list containing IP addresses and/or ranges of IP addresses.

List items can be in the format:




If the address is specified as a range, the range must be expanded into individual addresses, including the last address in the range. To simplify the task, we can assume that only the last octet of the address changes in the range.

The function returns a list of IP addresses.

For example, if you pass the following list to the convert_ranges_to_ip_list function:

['', '', '']

The function should return a list like this:

['', '', '', '', '',
 '', '', '', '']

Task 12.3#

Create a function print_ip_table that prints a table of available and unavailable IP addresses.

The function expects two lists as arguments:

  • list of available IP addresses

  • list of unavailable IP addresses

The result of the function is printing a table to the stdout:

Reachable    Unreachable
-----------  -------------