lunaiwa / iwazaki

MIT License
0 stars 1 forks source link

Project Check #2 #30

Open lunaiwa opened 1 year ago

lunaiwa commented 1 year ago

Individual 3 points

Tangible Artifacts 2018 MCQ Practice Test

Screen Shot 2023-04-18 at 9 30 37 AM

Q1 Swap values first and second

3.1

The code segment below is intended to swap the values of the variables first and second using a temporary variable, temp.

The block code consists of 3 lines. Line 1: temp, left arrow, first Line 2: first, left arrow, second Line 3: MISSING CODE

Which of the following can be used to replace missing code so that the code segment works as intended?

Answer B

This option is incorrect. The code segment assigns the initial value of first to temp, then assigns the initial value of second to first. The initial value of second, which has been stored in first, is then assigned to second. Therefore, the value of second has not changed from its initial value.

Q11 Simulate spinner with three unequal sections

3.15

A spinner is divided into three sections. The sector labeled Red is four times as large as each of the sectors labeled Blue and Yellow, which are of equal size.

The figure shows a spinner divided into 3 sections. The sector labeled Red is 4 times as large as each of the sectors labeled Blue and Yellow, which are of equal size.

The procedure below is intended to simulate the behavior of the spinner.

The block code consists of 2 lines. Begin block Line 1: PROCEDURE Spinner Line 2, indented 1 tab: begin block, MISSING CODE, end block End block

Which of the following can be used to replace missing code so that the procedure correctly simulates the spinner?

Answer D

This option is incorrect. The code segment simulates a spinner in which selecting each of three sections is equally likely.

Q21 Comparing robot algorithms

3.12

The following question uses a robot in a grid of squares. The robot is represented by a triangle, which is initially facing right.

The figure shows a grid of squares with 4 columns and 8 rows. The square in the first row and third column is gray, and all other squares are white. The square in the fourth row and first column contains a right-facing triangle, representing a robot. A path of arrows shows the robot’s movement from its initial location to the gray square. The path shows the robot moving 2 squares to the right from its initial location, then 3 squares up to the gray square.

Consider the procedures below.

The block code consists of 3 lines. Begin block Line 1: PROCEDURE, Move X Times, 1 word with capital M, X, and T, begin block, x, end block Begin block Line 2, indented 1 tab: REPEAT x TIMES Begin block Line 3, indented 2 tabs: MOVE underscore FORWARD End Block End block End block The block code consists of 3 lines. Begin block Line 1: PROCEDURE, Right X Times, 1 word with capital R, X, and T, begin block, x, end block Begin block Line 2, indented 1 tab: REPEAT x TIMES Begin block Line 3, indented 2 tabs: ROTATE underscore RIGHT End block End block End block

Which of the following code segments will move the robot to the gray square?

Answer B

This option is correct. This code segment moves the robot forward two squares, rotates it right three times so that the robot faces the top of the grid, and then moves the robot forward three squares to the gray square.

Developing Procedures

Calling Procedures