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
In what year did the manager and team depicted in the blockbuster film "Moneyball
mariarad [96]
2006 is the answer and the boston red sox were the first team to win 5 chamships 
3 0
3 years ago
Which of the following is the term for a device (usually external to a computer) that is plugged into a computer's communication
Serjik [45]

A device, usually external to a computer that is plugged into a computer's communication port or is connected wirelessly. Common peripherals are keyboards, mice, monitors, speakers, and printers

4 0
3 years ago
Which of the following operating systems includes a virtual assistant?<br> Group of answer choices
Anna [14]

Complete Question:

Which of the following operating systems includes a virtual assistant?

Group of answer choices

a. macOS

b. Linux

c. UNIX

d. Chrome OS

Answer:

a. macOS

Explanation:

Macintosh refers to a set of computers designed, developed and manufactured by Apple Inc. Apple officially began the sales of Macintosh on the 24th of January, 1984. The first designs of Macintosh are considered to be personal computers and had a mouse, in-built screen with a graphical user interface (GUI). The operating system designed and developed for Apple computers (MacBook) is known as macOS (Macintosh operating system).

A virtual assistant can be defined as a computer software program that is artificially intelligent to understand human voice commands and performs task for the end user based on instructions or commands.

Generally, macOS is an operating system that includes a virtual assistant referred to as Siri. Siri was developed and released by Apple on the 4th of October, 2011.

<em>Siri as a virtual assistant, is able to perform tasks such as setting reminders, scheduling events, media player controls, GPS navigation, internet search, answer some questions etc. </em>

3 0
3 years ago
Structure for forloop?
solong [7]

Answer:

for ( initialization; condition;increment)

{

code goes here;

}

in python:

for i in list/range:

code with proper indentation

By initialization above we mean, like int i=0; etc.

By condition like i<10;

and by increment it means like i++, ++i or i+=1; etc

And in python, i can be an integer value if the range is mentioned, and it can be an item of a list if the list is used. We can also use an array, string and various other data structures in python. like we can have characters in a string and so on.

Explanation:

Please check the answer section.

8 0
3 years ago
What are entity-relationship diagrams and how are they used? What symbol is used for a relationship? What is an associative enti
castortr0y [4]

Answer:

The definition including its given problem is outlined in the following segment on the clarification.

Explanation:

  • Entity-relationship (ER) diagram describes how mechanical stored procedures are constructed and demonstrate the overarching representation of the situation. It also describes the connections between some of the entities of the framework and even the comparison with standard measurements.
  • For something like an individual relationship structure, the normal representation of connections seems to be a diamond. Associative institutions have several to many partnerships to communicate with. It's indeed the verb throughout a diamond-shaped form that holds two organizations around each other. This verb is in fact an entity on its own, therefore it must be termed an associative entity.
  • An illustration of such might be if a participant were to register for a class. Multiple individuals will be registered for several courses, and there have been many to several relationships; thus, the associative object will indeed register.
4 0
3 years ago
Other questions:
  • The linux and macos program traceroute is known by a slightly different name on windows. it's referred to as ______.
    5·1 answer
  • Did you see the fire, uh, fireworks last night? Which of the following sentences is the most correct way to format this accordin
    15·2 answers
  • The source must decode a message before it can be sent. select one: <br> a. True <br> b. False
    7·1 answer
  • Create a structure named planet This structure will contain distance from Earth as an integer Atmosphere, language, people and p
    8·1 answer
  • Extinction of a species is always a negative impact on the Earth.<br><br> True<br> False
    8·1 answer
  • I am buying a BluRay drive access time is 180ms and the other is 210ms(BD-ROM) whats does access time mean
    5·1 answer
  • What is a WYSIWYG program?
    10·2 answers
  • A browser allows you to set preferences for using the browser. These preferences include all of the following except
    7·1 answer
  • Who like the videos where is clown is from :)
    6·1 answer
  • an engineer is writing a web application that requires some user input. the engineer has put a submit button on their page and n
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!