Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Do this code without importing re . An IP address is a set of four numbers that identifies a device on the internet or a

Do this code without importing re.
An IP address is a set of four numbers that identifies a device on the internet or a local area network. These four numbers are separated by period (.) when written in decimal representation. The four numbers are whole numbers limited from 0 up to 255. An IP address is valid if it consists of four numbers (limited from 0 up to 255) with periods in between (e.g.,192.168.0.1). Develop a function that will return a tuple of valid IP addresses in a given text.
import string
txt1= "Hello my ip address is 192.167.1.1 and I always listen to the radio 92.5. I know a lot about"\
"IP addresses and that 19.255.244.212 is a valid ip and 256.300.12.12 is not."
txt2= "Hackers get the IP address of people ... but I am not a hacker so I just ask them about it."\
"Sometimes they say 2.3.4.1 or 19.23.110.45. Others say 90.4532.22.345 but I know its wrong."
def list_valid_ip(text):
# This function extracts valid IP address from a given text
# YOUR CODE HERE
raise NotImplementedError()
txt1 should return ('192.167.1.1','19.255.244.212')
txt2 should return ("2.3.4.1","19.23.110.45")An IP address is a set of four numbers that identifies a device on the internet or a local area network. These four numbers are separated by period (.)
when written in decimal representation. The four numbers are whole numbers limited from 0 up to 255. An IP address is valid if it consists of four numbers
(limited from 0 up to 255) with periods in between (e.g.,192.168.0.1). Develop a function that will return a tuple of valid IP addresses in a given text.
In []: import string
txt1= "Hello my ip address is 192.167.1.1 and I always listen to the radio 92.5. I know a lot about"\
"IP addresses and that 19.255.244.212 is a valid ip and 256.300.12.12 is not."
txt2= "Hackers get the IP address of people ... but I am not a hacker so I just ask them about it."\
"Sometimes they say 2.3.4.1 or 19.23.110.45. Others say 90.4532.22.345 but I know its wrong."
def list_valid_ip(text):
# This function extracts valid IP address from a given text
# YOUR CODE HERE
raise NotImplementedError()
In []: # DO NOT MODIFY, THIS IS UNIT TESTING! [1 pt]
from nose.tools import assert_equal
assert_equal(list_valid_ip(txt1),('192.167.1.1','19.255.244.212'))
In []: # DO NOT MODIFY, THIS IS UNIT TESTING! [1 pt]
from nose.tools import assert_equal
assert_equal(1ist_valid_ip(txt2),("2.3.4.1","19.23.110.45"))
In []: # HIDDEN TEST [1 pt]
In []: # SAMPLE TEST, DO NOT MODIFY, JUST EXECUTE ONLY FOR OUTPUT
# You can add a cell below if you need to test a different input
print(list_valid_ip(txt1))
print(list_valid_ip(txt2))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions

Question

In Problem find the indicated derivative and simplify 3(+P)2 dr

Answered: 1 week ago

Question

2. Show the trainees how to do it without saying anything.

Answered: 1 week ago