AP Computer Science Principles Multiple Choice Practice (Part 3)

Поделиться
HTML-код
  • Опубликовано: 15 июл 2024
  • Problems taken from apcspths.pbworks.com/w/file/fe...
    Intro: 00:00
    Problem 1: 00:10
    Solving problem 1: 00:53
    Solution to problem 1: 03:00
    Problem 2: 03:24
    Solving problem 2: 04:30
    Solution to problem 2: 08:10
    Problem 3: 08:14Solving problem 3: 09:21
    Solution to problem 3: 15:08
    1. The following question uses a robot in a grid of squares. The robot is represented as a triangle, which is initially in the bottom left square of the grid and facing right. Consider the following code segment, which moves the robot in the grid.
    n ← 3
    REPEAT 3 TIMES
    REPEAT n TIMES
    MOVE_FORWARD
    ROTATE LEFT
    n ← n - 1
    Which of the following shows the location of the robot after running the code segment?
    2. Which of the following algorithms require both selection and iteration? Select two answers.
    (A) An algorithm that, given two integers, displays the greater of the two integers
    (B) An algorithm that, given a list of integers, displays the number of even integers in the list
    (C) An algorithm that, given a list of integers, displays only the negative integers in the list
    (D) An algorithm that, given a list of integers, displays the sum of the integers in the list
    3. A teacher uses the following program to adjust student grades on an assignment by adding 5 points to each student’s original grade. However, if adding 5 points to a student’s original grade causes the grade to exceed 100 points, the student will receive the maximum possible score of 100 points. The students’ original grades are stored in the list gradeList, which is indexed from 1 to n.
    i ← 1
    REPEAT n TIMES {
    {MISSING CODE}
    i ← i + 1
    }
    The teacher has the following procedures available:
    min (a, b) Returns the lesser of the two values a and b
    max (a, b) Returns the greater of the two values a and b
    Which of the following code segments can replace so that the program works as intended? Select two answers.
    (A) gradeList[i] ← min (gradeList[i] + 5, 100)
    (B) gradeList[i] ← max (gradeList[i] + 5, 100)
    (C) gradeList[i] ← gradeList[i] + 5
    IF (gradeList[i] is greater than 100) {
    gradeList[i] ← gradeList[i] - 5
    }
    (D) gradeList[i] ← gradeList[i] + 5
    IF (gradeList[i] is greater than 100) {
    gradeList[i] ← 100
    }

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