AP Computer Science Principles Multiple Choice Practice (Part 2)

Поделиться
HTML-код
  • Опубликовано: 15 июл 2024
  • Problems taken from apcspths.pbworks.com/w/file/fe...
    Problem 1: 00:00
    Solving problem 1: 00:52
    Four grids: 01:41
    Solution to problem 1: 06:06
    Problem 2: 07:20
    Solving problem 2: 07:50
    Solution to problem 2: 09:47
    Problem 3: 10:38Solving problem 3: 11:16
    Solution to problem 3: 13:14
    1) The program segment below is intended to move a robot in a grid to a gray square. The program segment uses the procedure GoalReached, which evaluates to true if the robot is in the gray square and evaluates to false otherwise. Te robot in each grid is represented as a triangle and is initially facing left. The robot can move into a white or gray square but cannot move into a black region.
    REPEAT UNTIL (GoalReached ()) {
    IF (CAN_MOVE (forward)) {
    MOVE_FORWARD ()
    }
    IF (CAN_MOVE (right)) {
    ROTATE_RIGHT ()
    }
    IF (CAN_MOVE (left)) {
    ROTATE_LEFT ()
    }
    }
    For which of the following grids does the program NOT correctly move the robot to the gray square?
    2) Biologists often attach tracking collars to wild animals. For each animal, the following geolocation data is collected at frequent intervals.
    * The time
    * The date
    * The location of the animal
    Which of the following questions about a particular animal could NOT be answered using only the data collected from the tracking collars?
    (A) Approximately how many miles did the animal travel in one week?
    (B) Does the animal travel in groups with other tracked animals?
    (C) Do the movement patterns of the animal vary according to the weather?
    (D) In what geographic locations does the animal typically travel?
    3) Consider the following program code.
    i = 0
    sum = 0
    REPEAT UNTIL i = 4
    i = 1
    sum = sum + i
    i = i + 1
    DISPLAY sum
    Which of the following best describes the result of running the program code?
    (A) The number 0 is displayed.
    (B) The number 6 is displayed.
    (C) The number 10 is displayed.
    (D) Nothing is displayed; the program results in an infinite loop.

Комментарии •