1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vlabodo [156]
3 years ago
15

Write a python program to read four numbers (representing the four octets of an IP) and print the next five IP addresses. Be sur

e to verify that the second, third and fourth numbers are between 0 and 255. The first one should be between 1 and 255.
Computers and Technology
1 answer:
sdas [7]3 years ago
8 0

Answer:

first_octet = int(input("Enter the first octet: "))

second_octet = int(input("Enter the second octet: "))

third_octet = int(input("Enter the third octet: "))

forth_octet = int(input("Enter the forth octet: "))

octet_start = forth_octet + 1

octet_end = forth_octet + 6

if (1 <= first_octet <= 255) and (0 <= second_octet <= 255) and (0 <= third_octet <= 255) and (0 <= forth_octet <= 255):

   for ip in range(octet_start, octet_end):

       forth_octet = forth_octet + 1

       if forth_octet > 255:

           forth_octet = (forth_octet % 255) - 1

           third_octet = third_octet + 1

           if third_octet > 255:

               third_octet = (third_octet % 255) - 1

               second_octet = second_octet + 1

               if second_octet > 255:

                   second_octet = (second_octet % 255) - 1

                   first_octet = first_octet + 1

                   if first_octet > 255:

                       print("No more available IP!")

                       break

       print(str(first_octet) + "." + str(second_octet) + "." + str(third_octet) + "." + str(forth_octet))

else:

   print("Invalid input!")

Explanation:

- Ask the user for the octets

- Initialize the start and end points of the loop, since we will be printing next 5 IP range is set accordingly

- Check if the octets meet the restrictions

- Inside the loop, increase the forth octet by 1 on each iteration

- Check if octets reach the limit - 255, if they are greater than 255, calculate the mod and subtract 1. Then increase the previous octet by 1.

For example, if the input is: 1. 1. 20. 255, next ones will be:

1. 1. 21. 0

1. 1. 21. 1

1. 1. 21. 2

1. 1. 21. 3

1. 1. 21. 4

There is an exception for the first octet, if it reaches 255 and others also reach 255, this means there are no IP available.

- Print the result

You might be interested in
15. How many PC’s can be connected to a UPS?
Alex_Xolod [135]

Answer: Depends on the power of the computer /computers and the UPS

Explanation: For someone who had a big connected network of computers and printers we would plug the computer or server into the UPS as well as the monitor and sometimes a printer sometimes the monitor was plugged into the wall

When you get a UPS you must plug it in for a certain time could be hours or even a day.  A USP has a big battery in it and you must charge it (sometimes it comes semi-charged but you must plug it in to strengthen it. )

there are two connector wires that you affix to the battery and you must put a lot of strength into it to make it secure.

So in closing, you can get away with two like a desktop and a laptop.

Read your documentation that comes with the UPS

6 0
1 year ago
Nearly all personal computers are capable of serving as network servers.
Mashutka [201]
True
yes computers are capable of serving network servers.
6 0
3 years ago
Read 2 more answers
Write a short quiz program which asks three true/false questions and stores the user's answers as booleans. At the end the progr
viva [34]

this answering question interface is bleh

8 0
3 years ago
What is the primary way to access applications in Windows 10
REY [17]

Try using cortana, it is usally preloaded on the computer.

Its close the windows start menu.

4 0
3 years ago
PLEASE HELP ME!!!!!! ITS FOR 100 POINTS AND BRAINLIEST!!!!!!!! NO ONE EVER WANTS TO ANSWER MY QUESTION!!! I JUST NEED SOMEONE TO
KonstantinChe [14]

Answer:

be creative

Explanation:

being creative helps you and our time brainstorm some good ideas that will help you succeed and allow your team mates to have a voice too if you follow these you will be a good team leader

i dont know if  if this the answer that your looking for but i hope it help

7 0
2 years ago
Read 2 more answers
Other questions:
  • Personal Web Page Generator Write a program that asks the user for his or her name, then asks the user to enter a sentence that
    11·1 answer
  • Template files can contain the following items: text, tables, images and lists.
    10·1 answer
  • While a threat intelligence analyst was researching an indicator of compromise on a search engine, the web proxy generated an al
    7·1 answer
  • Which f the following is not a characteristic of igneous rock
    8·1 answer
  • Assign a variable solveEquation with a function expression that has three parameters (x, y, and z) and returns the result of eva
    6·1 answer
  • George wants to edit the font of the title text in his presentation. Where can he find the option to edit it?
    6·2 answers
  • Which best describes a difference between transcription and DNA replication
    8·2 answers
  • Counselors do NOT provide which service during treatment?
    12·2 answers
  • What is your impression on the subject fundamentals of database systems?​
    7·1 answer
  • Information that indicates ground air or navy force levels or dispositions is what security?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!