I got a 39/50.

from IPython.display import Image, display
from pathlib import Path  # https://medium.com/@ageitgey/python-3-quick-tip-the-easy-way-to-deal-with-file-paths-on-windows-mac-and-linux-11a072b58d5f

# prepares a series of images
def image_data(path=Path("images/"), images=None):  # path of static images is defaulted
    if images is None:  # default image
        images = [
            {'source': "Peter Carolin", 'label': "Clouds Impression", 'file': "MCQ.jpg"},
        ]
    for image in images:
        # File to open
        image['filename'] = path / image['file']  # file with path
    return images

def image_display(images):
    for image in images:  
        display(Image(filename=image['filename']))


# Run this as standalone tester to see sample data printed in Jupyter terminal
if __name__ == "__main__":
    # print parameter supplied image

    # display default images from image_data()
    default_images = image_data()
    image_display(default_images)
    

Review over questions I got wrong:


  • Question 9

A Web site uses several strategies to prevent unauthorized individuals from accessing user accounts. Which of the following is NOT an example of multifactor authentication?

A (Answer I Chose) Each employee for a company is issued a USB device that contains a unique token code. To log into a company computer, an employee must insert the USB device into the computer and provide a correct password.

B After logging into an account from a new device, a user must enter a code that is sent via e-mail to the e-mail address on file with the account.

C In order to log into an account, a user must provide both a password and a fingerprint that is captured using the user’s device.

D (Correct Answer) When a user enters an incorrect password more than two times in a row, the user is locked out of the account for 24 hours.


  • Question 22

Two grids are shown below. Each grid contains a robot represented as a triangle. Both robots are initially facing left. Each robot can move into a white or gray square, but cannot move into a black region.

Two grids are shown, each three boxes across and five boxes high. The grid on the left is labeled Grid 1 and the grid on the right is labeled Grid 2. Each grid has a grey square in the upper left corner and an arrow pointing to the left in the square in the lower right corner. In Grid 1 the first two squares in the second row and the last two squares in the fourth row are black. In Grid 2 the first and third squares in the second row, the third square in the third row, and the last two squares in the fourth row are black. The remaining squares are white in both grids.

For each grid, the program below is intended to move the robot to the gray square. The program uses the procedure Goal_Reached ( ), which evaluates to true if the robot is in the gray square and evaluates to false otherwise.

A coding program reads as follows. Line 1: Repeat until left parenthesis Goal underscore Reached left parenthesis right parenthesis right parenthesis. Line 2: Left curly bracket. Line 3: If left parenthesis can underscore move open parenthesis right close parenthesis. Line 4: Left curly bracket. Line 5: Rotate underscore right left parenthesis right parenthesis. Line 6: Right curly bracket. Line 7: Else. Line 8: Left curly bracket. Line 9: If left parenthesis can underscore move left parenthesis left right parenthesis right parenthesis. Line 10: Left curly bracket. Line 11: Rotate underscore left parenthesis right parenthesis. Line 12: Right curly bracket. Line 13: Right curly bracket. Line 14: If left parenthesis can underscore move left parenthesis forward right parenthesis right parenthesis. Line 15: Left curly bracket. Line 16: Move underscore forward left parenthesis right parenthesis. Line 17: Right parenthesis.

For which of the grids does the program correctly move the robot to the gray square?

A (Correct Answer) Grid I only

B Grid II only

C Both grid I and grid II

D (Answer I chose) Neither grid I nor grid II


  • Question 28

Consider the following procedures for string manipulation.

Procedure Call Explanation concat(str1, str2) Returns a single string consisting of str1 followed by str2. For example, concat("key", "board") returns "keyboard". substring(str, start, length) Returns a substring of consecutive characters from str, starting with the character at position start and containing length characters. The first character of str is located at position 1. For example, substring("delivery", 3, 4) returns "live". len(str) Returns the number of characters in str. For example, len("pizza") returns 5. Assume that the string oldString contains at least 4 characters. A programmer is writing a code segment that is intended to remove the first two characters and the last two characters from oldString and assign the result to newString.

For example, if oldString contains "student", then newString should contain "ude".

Which of the following code segments can be used to assign the intended string to newString ?

Select two answers.

A (Correct Answer) newString ← substring(oldString, 3, len(oldString) - 4)

B newString ← substring(oldString, 3, len(oldString) - 2)

C tempString ← substring(oldString, 3, len(oldString) - 2)

newString ← substring(tempString, 1, len(tempString) - 2)

D (Correct Answer) tempString1 ← substring(oldString, 1, 2)

tempString2 ← substring(oldString, len(oldString) - 2, 2)

newString ← concat(tempString1, tempString2)

I didn't really understand what this question was asking.


  • Question 29

Consider the following code segment.

The figure presents eight blocks of code that consist of 8 total lines. Line 1: [begin block] a ← true [end block] Line 2: [begin block] b ← false [end block] Line 3: [begin block] c ← true [end block] Line 4: [begin block] a ← [begin block] NOT [begin block] a OR b [end block] [end block] AND c [end block] Line 5: [begin block] c ← c AND a [end block] Line 6: [begin block] DISPLAY [begin block] a [end block] [end block] Line 7: [begin block] DISPLAY [begin block] b [end block] [end block] Line 8: [begin block] DISPLAY [begin block] c [end block] [end block] What is displayed as a result of executing the code segment?

A true true true

B (Correct Answer) false false false

C true false true

D (Answer I chose) false false true


  • Question 33

The following grid contains a robot represented as a triangle, which is initially facing right.

The figure presents a robot in a 6 by 6 grid of squares. The robot is represented by a triangle, which is initially in the third square from the left in the fifth row, facing right. The third row contains gray shading in the third square from the left. The following code segment is intended to move the robot to the gray square.

{

REPEAT 4 TIMES

{

MOVE_FORWARD()

ROTATE_RIGHT()

}

ROTATE_LEFT()

MOVE_FORWARD()

ROTATE_RIGHT()

}

Which of the following can be used as a replacement for so that the code segment works as intended?</p>

A REPEAT 1 TIMES

B (Correct Answer) REPEAT 2 TIMES

C REPEAT 3 TIMES

D (Answer I chose) REPEAT 4 TIMES


  • Question 38

Consider the following code segment with an integer variable num.

IF(num > 0)

{

DISPLAY("positive")

}

IF(num < 0)

{

DISPLAY("negative")

}

IF(num = 0)

{

DISPLAY("zero")

}

Which of the following code segments is equivalent to the code segment above?

A (Answer I chose) IF(num < 0)

{

DISPLAY("negative")

}

ELSE

{

DISPLAY("positive")

}

IF(num = 0)

{

DISPLAY("zero")

}

B (Correct Answer) IF(num < 0)

{

DISPLAY("negative")

}

ELSE

{

IF(num = 0)

{

DISPLAY("zero")

}

ELSE

{

DISPLAY("positive")

}

}

C IF(num ≤ 0)

{

DISPLAY("negative")

}

ELSE

{

IF(num = 0)

{

DISPLAY("zero")

}

ELSE

{

DISPLAY("positive")

}

}

D IF(num ≤ 0)

{

DISPLAY("negative")

}

IF(num = 0)

{

DISPLAY("zero")

}

ELSE

{

DISPLAY("positive")

}


  • Question 39

The following question uses a robot in a grid of squares. The robot is represented as a triangle, which is initially facing toward the top of the grid.

The figure presents a robot in a 5 by 5 grid of squares. The robot is represented by a triangle, which is initially located in the second square from the left in the fourth row, facing upward. The following code segment moves the robot around the grid. Assume that n is a positive integer.

Line 1: count ← 0

Line 2: REPEAT n TIMES

Line 3: {

Line 4: REPEAT 2 TIMES

Line 5: {

Line 6: MOVE_FORWARD()

Line 7: }

Line 8: ROTATE_RIGHT()

Line 9: }

Consider the goal of modifying the code segment to count the number of squares the robot visits before execution terminates. Which of the following modifications can be made to the code segment to correctly count the number of squares the robot moves to?

A (Correct Answer) Inserting the statement count ← count + 1 between line 6 and line 7

B (Answer I chose) Inserting the statement count ← count + 2 between line 6 and line 7

C Inserting the statement count ← count + 1 between line 8 and line 9

D Inserting the statement count ← count + n between line 8 and line 9


  • Question 40

The following grid contains a robot represented as a triangle, which is initially in the bottom-left square of the grid and facing the top of the grid. The robot can move into a white or a gray square but cannot move into a black region.

The figure presents a robot in a 5 by 5 grid of squares. The robot is represented by a triangle, which is located in the bottom leftmost square and is initially facing upward. Black squares represent barriers that the robot cannot pass through. The first row contains black shading in the first, second, third, and fourth squares from the left and gray shading in the fifth square from the left. The second row contains black shading in the first, second, third, and fourth squares from the left. The fourth row contains black shading in the second, third, fourth, and fifth squares from the left. The fifth row contains black shading in the second, third, fourth and fifth squares from the left. The following code segment implements an algorithm that moves the robot from its initial position to the gray square and facing the top of the grid.

The figure presents five blocks of code that consist of 8 total lines. Throughout the first, third, and fifth blocks of code are nested blocks of code. [begin block] Line 1: REPEAT 2 TIMES [begin block] Line 2: [begin block] MOVE_FORWARD [end block] [end block] [end block] Line 3: [begin block] ROTATE_RIGHT [end block] [begin block] Line 4: REPEAT 4 TIMES [begin block] Line 5: [begin block] MOVE_FORWARD [end block] [end block] [end block] Line 6: [begin block] ROTATE_LEFT [end block] [begin block] Line 7: REPEAT 2 TIMES [begin block] Line 8: [begin block] MOVE_FORWARD [end block] [end block] [end block] When the robot reaches the gray square, it turns around and faces the bottom of the grid. Which of the following changes, if any, should be made to the code segment to move the robot back to its original position in the bottom-left square of the grid and facing toward the bottom of the grid?

A (Answer I chose) Interchange the ROTATE_RIGHT and the ROTATE_LEFT blocks.

B Replace ROTATE_RIGHT with ROTATE_LEFT.

C Replace ROTATE_LEFT with ROTATE_RIGHT.

D (Correct Answer) No change is needed; the algorithm is correct as is.


  • Question 42

Suppose that a list of numbers contains values [-4, -1, 1, 5, 2, 10, 10, 15, 30]. Which of the following best explains why a binary search should NOT be used to search for an item in this list?

A The list contains both positive and negative elements.

B (Correct Answer) The elements of the list are not sorted.

C The list contains an odd number of elements.

D (Answer I chose) The list contains duplicate elements.

I didn't see that the 5 was before the 2.


  • Question 49

A city planner is using simulation software to study crowd flow out of a large arena after an event has ended. The arena is located in an urban city. Which of the following best describes a limitation of using a simulation for this purpose?

A (Answer I chose) The model used by the simulation software cannot be modified once the simulation has been used.

B (Correct Answer) The model used by the simulation software often omits details so that it is easier to implement.

C Running a simulation requires more time to generate data from trials than observing the crowd exiting the arena at various events.

D Running a simulation requires a large number of observations to be collected before it can be used to explore a problem.


  • Question 50

A computer scientist is analyzing four different algorithms used to sort a list. The table below shows the number of steps each algorithm took to sort lists of different sizes.

List Size
Number of Steps

for Algorithm A

Number of Steps

for Algorithm B

Number of Steps

for Algorithm C

Number of Steps

for Algorithm D

1 10 2 1 1 2 20 4 2 4 3 30 8 6 9 4 40 16 24 16 5 50 32 120 25 Based on the values in the table, which of the algorithms appear to run in reasonable time?

Select two answers.

A (Correct Answer) Algorithm A

B (Answer I chose) Algorithm B

C Algorithm C

D (Correct Answer) Algorithm D

Reflection

There isn't much to reflect over. I thought I did well on the quiz but unfortunately I did not. I will use these mistakes to better myself moving forward.

</div> </div> </div> </div>