Intro to programming responses

Provide (2) 200 words response with a minimum of 1 APA references for RESPONSES 1 AND 2 below. Response provided should further discuss the subject or provide more insight. To further understand the response, below is the discussion post that’s discusses the responses. 100% original work and not plagiarized. Must meet deadline.

RESPONSE 1:

An if-then script simply takes an argument from a variable and checks to see if it is true. If it is true, then it executes the parameter. If it is false, then it executes a different parameter which can be another defined variable or an exit condition. Loops repeats the processed if-then program as many times as indicated within the set parameters until an exit condition is reached. The loop needs an exit condition that can be met or it can become an endless loop, or infinite loop. An infinite loop can accidentally use up 100% of your CPU usage that will lock up your device or cause it to crash. Ways to avoid an endless loop is to always make sure to set an exit condition that can be met, or makes sense to the language you are programming in. There may be a “continue” statement with another variable that could be out of place preventing the code to move on and continuously loop. Another way to prevent infinite loops is to set timeout conditions in your code. Also, if you are working with complex loops that have the potential to be endless, you may consider testing your code first through a walk-through program, such as the Python Tutor we will be using in this class and others such as Google Chrome Dev Tools. This will allow you to step through and visualize what your program is doing.

Endless loops can create a denial of service (DOS). You may accidentally DOS yourself! In fact, you can set up a simple script that throws specific types of packets to a single router or switch interface (IP and port range) over and over again causing a denial of service effect. You can also overwhelm firewalls by doing this, especially if they are doing deep packet inspections. There are several quirky vulnerabilities out there listed in the MITRE CVE that has exploits like this already written and tested. Building a virtual range to test these out is a lot of fun and you learn networking quickly.

RESPONSE 2:

This week we learned about variables along with creating loops and if-then scripts. Our textbook, Microsoft WSH and VBScript Programming for the Absolute Beginner, 4th Ed. by Jerry L. Ford, defines a variable as “an individual piece of data such as a name, number, or date that is stored in memory” (2014, p. 85). Variables are the numbers, dates or names in which you are looking for or defining in your scripts. For example, in this week’s practice scripts, fnum, snum, and total were the variables that were being defined. Once we defined are variables, we were able to look more into loops and if-then scripts.

Loops are “collection of statements repeatedly executed to facilitate the processing of large amounts of data” (Ford, 2014, p. 144). Loops could be used to repeat a certain function until the end condition is met. For example, in this week’s practice loop script, we set a up a loop where the program would produce numbers between the first variable, fnum, to the second variable, snum. Once the computer reached snum, the condition was met and the loop ended. The if-then script we learned included a loop, however, the loop would only run if the second number we typed was greater than the first number we chose. If the first number was larger than the second number, the loop would not run. In order to run the loop, the condition must be met prior to the program running the script. The whole purpose of the if-then script is to determine if the argument depicted in the script is accurate based off the variables provided. If the variables make the script accurate then it runs; if not, then it doesn’t run the script.

When creating loops, individuals might incorrectly type an “exit function” or create an improper condition to stop the loop. If this happens, an endless loop could be created. Based off initial research, endless loops are not necessarily dangerous, but rather annoying. Most people can exit an endless loop by doing a hard-exit of the program, or even shutting down their computer. However, some individuals might create an endless loop in order to create a DoS (Denial of Service) attack. DoS attacks are meant to prevent a person from using a certain program, and if someone was stuck in an endless loop, they would not be able to use that program until they manage to exit or stop the loop.

Tags: No tags