Scenario: IPv4 addresses (used to communicate on a network) have 4 numbers with 3 decimal points between them with each number being called an octet. For example, 1.2.3.4. 1 is an octet, 2 is an octet, and so on. The first octet has to have values between 1-255 while the 2nd-4th octets can have values between 0-255. The IP addresses are divided into classes A, B, C, D and E based upon the value of the first octet. See the table below. Students preparing for the CompTIA A+ certification (those taking CTS1131 Computer Home/Small Office Essentials and CTS1132 PC Technician who are majoring in CIT, Networking or IT Security) will have the following options to choose from in preparing to study these concepts and need to focus on class A, B and C: 1. Identify the class: Given an IP address, the user answers with an "A", "B" or "C". 2. Provide the default subnet mask: Given an IP address, the user answers with the appropriate default subnet mask. 3. Exit: The program ends. Once the user selects one of the options, it will initially state what option it is and provide the question related to that option. When the user types in an answer, the program will tell them whether they were correct or incorrect and then give them another question. If the user types in "q", it will take them back to the main menu. If the user hits Enter without typing anything, the user is re-prompted with the same prompt. Class Octet Range Default Subnet Mask A 1-127* 255.0.0.0 B 128-191 255.255.0.0 C 192-223 255.255.255.0 *127 is loopback and some people do not consider it to be part of class A. For the purposes of this assignment, it'll be part of Class A. Create the python program that solves the problem in the scenario. Make sure to format it as seen in the screenshot below. Formatting means the prompts for the user should be spelled and written the same way as seen in the screenshot as well as the spacing between outputs (single-spaced, double-spaced, etc.) should also match. Make sure variable values are formatted the same way as seen in the screenshot. Any task that will be repeated over and over should be put in its own function. Each function should logically do one thing and only that well. Make sure to divide your program appropriately into functions. Any program that doesn't use functions or only uses one function (such as a main function) You MUST create and use the following functions EXACTLY as specified as the instructor will review this methods but also run test cases against them: whatClass(address) - where address is the IP address (as a string) and the function returns a string result of whether the given IP address is a Class "A", "B" or "C" address. It should only return the letter of the class as a string. whatSM(address) - where address is the IP address (as a string) and the function returns the result of the subnet mask for the given IP address. generateRandomIP() - which generates a random IP address and returns it (as a string). Make sure to follow good programming practices as mentioned in Good and Bad Programming Practices. You should only use modules/libraries we have covered thus far. If the program doesn't put the code appropriately into functions, The portions above in red italics describing the functions were added to clarify for this new due date. Note: address must be a string and when a random IP address is generated, it should be a string.
Scenario: IPv4 addresses (used to communicate on a network) have 4 numbers with 3 decimal points between them with each number being called an octet. For example, 1.2.3.4. 1 is an octet, 2 is an octet, and so on. The first octet has to have values between 1-255 while the 2nd-4th octets can have values between 0-255. The IP addresses are divided into classes A, B, C, D and E based upon the value of the first octet. See the table below. Students preparing for the CompTIA A+ certification (those taking CTS1131 Computer Home/Small Office Essentials and CTS1132 PC Technician who are majoring in CIT, Networking or IT Security) will have the following options to choose from in preparing to study these concepts and need to focus on class A, B and C:
1. Identify the class: Given an IP address, the user answers with an "A", "B" or "C".
2. Provide the default subnet mask: Given an IP address, the user answers with the appropriate default subnet mask.
3. Exit: The program ends.
Once the user selects one of the options, it will initially state what option it is and provide the question related to that option. When the user types in an answer, the program will tell them whether they were correct or incorrect and then give them another question. If the user types in "q", it will take them back to the main menu. If the user hits Enter without typing anything, the user is re-prompted with the same prompt.
Class | Octet Range | Default Subnet Mask |
A | 1-127* | 255.0.0.0 |
B | 128-191 | 255.255.0.0 |
C | 192-223 | 255.255.255.0 |
*127 is loopback and some people do not consider it to be part of class A.
For the purposes of this assignment, it'll be part of Class A.
Create the python program that solves the problem in the scenario. Make sure to format it as seen in the screenshot below. Formatting means the prompts for the user should be spelled and written the same way as seen in the screenshot as well as the spacing between outputs (single-spaced, double-spaced, etc.) should also match. Make sure variable values are formatted the same way as seen in the screenshot.
Any task that will be repeated over and over should be put in its own function. Each function should logically do one thing and only that well. Make sure to divide your program appropriately into functions. Any program that doesn't use functions or only uses one function (such as a main function)
You MUST create and use the following functions EXACTLY as specified as the instructor will review this methods but also run test cases against them:
whatClass(address) - where address is the IP address (as a string) and the function returns a string result of whether the given IP address is a Class "A", "B" or "C" address. It should only return the letter of the class as a string.
whatSM(address) - where address is the IP address (as a string) and the function returns the result of the subnet mask for the given IP address.
generateRandomIP() - which generates a random IP address and returns it (as a string).
Make sure to follow good
You should only use modules/libraries we have covered thus far.
If the program doesn't put the code appropriately into functions,
The portions above in red italics describing the functions were added to clarify for this new due date. Note: address must be a string and when a random IP address is generated, it should be a string.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 4 images