Test Corrections

I scored 62/67. I got questions 15, 16, 58, 62, and 64 wrong.

Q15

Both programs print ten values. Program A initializes i to 1. Inside the loop, it prints i and then increments i. The loop terminates when i is greater than 10, which occurs after 10 is printed. Program A prints 1 2 3 4 5 6 7 8 9 10. Program B initializes i to 0. Inside the loop, it increments i and then prints i. The loop terminates when i equals 10, which occurs after 10 is printed. Program B prints 1 2 3 4 5 6 7 8 9 10.

Q16

Inserting the incorrect statement between lines 6 and 7 means that index is only decremented when an occurrence of “the” or “a” is found. Instead, index should be decremented after each element is checked. The program traverses wordList starting at the end of the list and moving to the start of the list, removing any elements that are equal to “the” or “a” along the way. Inserting the correct statement between lines 7 and 8 decrements index after checking each list element, ensuring that all elements are checked.

Q58

For the incorrect set of inputs, the IF condition x = y evaluates to false, so the body of the ELSE statement is executed. The expression y = z evaluates to false, so false is returned as intended. For the correct of inputs, false is returned even though two of the inputs are equal in value. The IF condition x = y evaluates to false, so the body of the ELSE statement is executed. The expression y = z evaluates to false, so false is returned.

Q62

Since x is true, the body of the IF statement is executed. Since x OR y evaluates to true, true is displayed. Since x OR y evaluates to true, the body of the IF statement is executed. Since x is true, true is displayed. I fully understand this one, I just did not see the instruction saying to select two answers instead of one.

Q64

For the incorrect values, the procedure repeatedly adds -2 to result five times, resulting in the intended product -10. For the correct values, since y is initially negative, the loop condition count ≥ y is initially true, so the body of the loop is never executed and 0 is returned. And, since y is initially negative, the loop condition count ≥ y is initially true, so the body of the loop is never executed and 0 is returned.

Reflection

After taking this test, I feel like I am familiar enough with all the concepts, it is just a matter of reading the questions deeper, and stop making silly mistakes. I may need to practice more porblems with sequencing and boolean, as I made a lot of silly mistakes with those problems.