Continue from the previous question, modify the following in the IP_address class. :
For example, consider the following code fragment
ip_key = '192.168.0.24' data_list =[(0, 84), (1, 84), (2, 84), (3, 84), (4, 84), (5, 84), (6, 84), (7, 84), (8, 84), (9, 84), (10, 84), (11, 84), (12, 84), (13, 84), (14, 84), (15, 84), (16, 84), (17, 84), (18, 84), (19, 84), (20, 84)] size = 3 ip = IP_address(key, data_list, size)
The data_list contains a list of tuple objects. Each tuple consists of the time-frame value and the packet-size. You should summarize this list and create a frequency list, a sum list and an average list based on the time-frame value. There are a lot of data for each time-frame value, we will group packet-size values together. For example: the above data_list will be divided into 3 groups:
Continue from the previous question, modify the following in the IP_address class. :
For example, consider the following code fragment:
Thanks for the question, here are the implemented functions - get_statistics() and __str()__
I have used the sample example to test these two functions and its working fine. Incase, any one test case fail do let me know so that I can change the code accordingly.
thanks a lot !
==================================================================
class IP_address():
def __init__(self, ip,
data_list, size):
self.ip_address =
ip
self.data_list =
data_list
self.size = size
def get_statistics(self):
total_data_size =
sum(packet[1] for packet in
self.data_list)
total_packets=len(self.data_list)
average_packet_size=int(total_data_size/total_packets)
return
'{}, {}, {},
{}'.format(self.ip_address,total_data_size,total_packets,average_packet_size)
def __str__(self):
desc =
self.ip_address
statistics = []
for i
in range(0, len(self.data_list), 10):
data = self.data_list[i: i + 10]
frequency = len(data)
sum_data = sum([packet[1] for packet
in data])
average = round(sum_data / frequency, 1)
statistics.append([frequency, sum_data, average])
desc +=
':freq=[{}]'.format(',
'.join([str(data[0]) for data
in statistics]))
desc +=
',sum=[{}]'.format(',
'.join([str(data[1]) for data
in statistics]))
desc +=
',avg=[{}]'.format(',
'.join([str(data[2]) for data
in statistics]))
return
desc
ip_key = '192.168.0.24'
data_list = [(0, 84), (1, 84), (2, 84), (3, 84), (4, 84), (5, 84),
(6, 84), (7, 84), (8, 84), (9, 84), (10, 84),
(11, 84),
(12, 84), (13, 84), (14, 84), (15, 84), (16, 84), (17, 84), (18,
84), (19, 84), (20, 84)]
size = 3
ip = IP_address(ip_key, data_list, size)
print(ip.get_statistics())
print(ip)
thanks a lot !
Continue from the previous question, modify the following in the IP_address class. : add a method...
Python Design a class named IP_address to represent IP address objects. The IP_addressclass contains the following A number of instance variables/fields to store a table of data. You can design them on your own. A constructor that creates a table with the following: a list of data. IP address an integer to indicate the number of elements in the sum_list/freq_list/average_list A get_ip_address() method that returns the IP address For example, consider the following code fragment: ip_key = '192.168.0.24' data_list =[(0,...
python 3.7 write a function called read_file() which accepts a filename and returns a list of tuple objects. For example, if we have the following data: 0.000000000 192.168.0.24 10.0.0.5 H-NM 1.001451000 192.168.0.24 10.0.0.5 2.002970000 192.168.0.24 10.0.0.5 3.003552000 192.168.0.24 10.0.0.5 4.005007000 192.168.0.24 10.0.0.5 then the list should contain the following: [('192.168.0.24', 0, 84), ('192.168.0.24', 1, 84), ('192.168.0.24', 2, 84), ('192.168.0.24', 3, 84), ('192.168.0.24', 4, 84)] Note: • Each line consists of a number of fields separated by a single tab character....
Problem 6. The set (Z19 − {0}, ·19) is a group with the indicated operation; see the attached table. a.) Show that H = {1, 7, 8, 11, 12, 18} is a subgroup. b.) List all the right cosets of H. c.) Show that if Hy = Hx then xy−1 ∈ H. [Make sure to give a reason for each step.] d.) Show that φ : H → Hx defined by φ(h) = hx is one-to-one and onto. [Use the...
1 question is this choose mcq quickly 10 p The following data represent the total number of years of formal education for 40 employees of a bank. 13 17 13 14 12 17 19 13 15 13 16 18 13 11 19 19 14 15 13 15 17 18 17 14 13 17 12 17 17 16 16 17 15 13 13 14 12 14 1313 Construct a frequency distribution for the number of years of education. Number of years...
Suppose there are 100 identical firms in the market and the luggage industry is perfectly competitive. What does the market supply curve look like? 20 19 18 17 16 15 14 13 12 11 A 10 9 8 7 6 5 4 20 19 18 17 16 15 14 13 12 11 A 10 8 7 6 2 1 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5...
For C++ Write a program that randomly generates 100 integers and sorts them using radix sort. Note: Your output would not be the same as this sample output due to the randomness. Sample output: 0 0 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 4 4 4 4 4 4 4 4 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7...
10. In a network an IP address and prefix is given as 192.168.130.34/17. What is the subnet mask? (A) 0.0.127.255 (B) 255.255.0.0 (C) 255.255.128.0 (D) 0.0.2.34 11. In a network an IP address and prefix are given as 192.168.130.34/17. How many host addresses are there? (A) 34 (B) 32766 (C) 131072 (D) 2 12. One result of subnetting is that the size of the routing table in the routers is reduced (A) True (8) False 13. The port number is...
(9 marks) Complete the following methods in the class MyLinkedList based the description provided. b. on i. (3 marks) size() return the number of items in the list. i. (3 marks) count Positives (): return the number of positive values in the list ii. (3 marks) (Advanced) reverse the order of the items in reverse ( the list. If the list is 10 90, then after calling the - 70 - 20 -> method, it should become 90 - 70...
Use the create_matrix function from the tutorial file, along with a function a (i, j) (which you will have to create) to produce the following 17 × 17 matrix. Then find its determinant. 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 6 1 1 1 1 1 1 1 1 1 1 1...
The following five independent random samples are obtained from five normally distributed populations with equal variances. The dependent variable is the number of bank transactions in 1 month, and the groups are five different banks. Group 1 Group 2 Group 3 Group 4 Group 5 16 16 2 5 7 5 10 9 8 12 11 7 11 1 14 23 12 13 5 16 18 7 10 8 11 12 4 13 11 9 12 23 9 9 19...