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]
4 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]4 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
"HotelExp” is a 3-D range name applied to the workbook shown.
Ganezh [65]

Answer:

all cells in the B column of any worksheet in this workbook

Explanation:

It seems each worksheet covers total expenses for each month, and hence workbook must have 12 such with one month for each worksheet. Also, the 3D range is a special option in Excel to reference all cells or a selected group of cells for all the worksheets. However, it should be all B cells as B2: B4 apart from this, others in B column also has expenses. And hence, the above option is the correct one.

3 0
3 years ago
Many programming languages require a ____ to create executable files.
Nadya [2.5K]
Most languages require a compiler. This is because machine code consists of only 0s and 1s, which is executable. All other languages have to be translated into machine language by a compiler.
4 0
4 years ago
Write a program to help a travelling sales person keep up with their daily mileage driven for business. In your main method, the
Lelu [443]

Answer:

The programming language is not stated;

<em>The program written in C++ is as follows (See Explanation Section for detailed explanation);</em>

#include<iostream>

using namespace std;

int main()

{

 int numdays;

 cout<<"Number of days of mileage: ";

 cin>>numdays;

 int miles[numdays];

for(int i=0;i<numdays;i++)

{

 cout<<"Miles traveled on day "<<i+1<<": ";

 cin>>miles[i];

}

 int total = 0;

 for(int i=0;i<numdays;i++)

{

 total+=miles[i];

}

cout<<"Total mileage traveled: "<<total;

 return 0;

}

Explanation:

This line declares the number of days of mileage

 int numdays;

This line prompts user for days of mileage

 cout<<"Number of days of mileage: ";

This line accepts input from the traveler for days of mileage

 cin>>numdays;

This line creates an array

 int miles[numdays];

The italicized is an iteration that collects the user input for each day

<em> for(int i=0;i<numdays;i++)</em>

<em> {</em>

<em>  cout<<"Miles traveled on day "<<i+1<<": ";</em>

<em>  cin>>miles[i];</em>

<em> }</em>

This line initializes variable to 0

 int total = 0;

The italicized is an iteration that adds up the mileage traveled by the traveler each day  

<em>  for(int i=0;i<numdays;i++)</em>

<em> {</em>

<em>  total+=miles[i];</em>

<em> }</em>

This line prints the total miles traveled

cout<<"Total mileage traveled: "<<total;

5 0
4 years ago
You are the network administrator for your company. You want to look at some of the resources on the network. Specifically, you
mr Goodwill [35]

Answer:

" Performance Monitor" is the correct solution.

Explanation:

  • The most comprehensive method or indication for viewing but mostly analysis of those same applications as well as hardware-related issues would be determined as "Performance monitor."
  • Performance Monitoring seems to be a combination of methods as well as technologies to assess relatively quickly apps work throughout the data center.

3 0
4 years ago
A student has a ten-year-old desktop computer that she only uses for word processing, but she would like to start using it to pl
wariber [46]

Answer:

She should buy a new one or buy a Gaming PC to upgrade the setup.

Explanation:

6 0
3 years ago
Other questions:
  • What is alphabet symmetry
    12·2 answers
  • TRUE OR FALSE!!!!!
    6·2 answers
  • The best-known communications protocol is probably smtp, which regulates internet data transport. _________________________
    6·1 answer
  • Define decomposition
    9·1 answer
  • What is an online recommendation engine?
    9·1 answer
  • In excel online what is it called when you join connecting cells together to span across more than one column and/or row?
    7·2 answers
  • The History feature of a browser enables you to retrace your browsing history over a short period of time. (1 point) True False
    9·1 answer
  • URGENT! Drag the tiles to the correct boxes to complete the pairs.
    7·1 answer
  • Briefly explain the importance of doing backup in systems administration and explain in detail any three methods for performing
    7·1 answer
  • When conducting memory and recall tests, some people make an effort to normalize memories by not reporting extreme cases. this l
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!