Using Programs with Data MCQ Practice

Question 1 of 10

Lap times in seconds:

Runner Lap1 Lap2 Lap3
Jia 50 48 49
Ken 47 47 46
Liv 52 51 50
Mo 49 48 48

A program creates Total = Lap1+Lap2+Lap3 and keeps runners with Total ≤ 145. Who remains?

  1. A. All four runners
  2. B. Jia and Ken
  3. C. Ken and Mo
  4. D. Liv only

Question 2 of 10

Using the lap table:

Runner Lap1 Lap2 Lap3
Jia 50 48 49
Ken 47 47 46
Liv 52 51 50
Mo 49 48 48
sum ← 0
FOR EACH row IN table
{
    sum ← sum + row.Lap3
}
DISPLAY(sum / 4)

What average Lap3 time is displayed?

  1. A. 49
  2. B. 47
  3. C. 193
  4. D. 48.25

Question 3 of 10

words ← ["data", "bit", "code", "file"]

i ← 1
REPEAT UNTIL i > 4
{
    IF LENGTH(words[i]) = 4
    {
        DISPLAY(words[i])
    }
    i ← i + 1
}

Which output sequence is produced?

  1. A. data then code then file
  2. B. bit then code
  3. C. data then bit then code then file
  4. D. file only

Question 4 of 10

Using the lap table, a program searches for the first runner (top to bottom) whose Lap1 < 49 and displays that Runner name.

Runner Lap1 Lap2 Lap3
Jia 50 48 49
Ken 47 47 46
Liv 52 51 50
Mo 49 48 48

What is displayed?

  1. A. Jia
  2. B. Ken
  3. C. Liv
  4. D. Mo

Question 5 of 10

Sensor table:

ID Reading
1 10
2 14
3 9
4 14
5 11
count ← 0
FOR EACH row IN table
{
    IF row.Reading = 14
    {
        count ← count + 1
    }
}
DISPLAY(count)

What is displayed?

  1. A. 5
  2. B. 1
  3. C. 2
  4. D. 4

Question 6 of 10

A program keeps only lap-table rows where Lap3 ≤ 48 and then averages Lap2 of remaining rows.

Runner Lap1 Lap2 Lap3
Jia 50 48 49
Ken 47 47 46
Liv 52 51 50
Mo 49 48 48

What average Lap2 results?

  1. A. 48
  2. B. 49
  3. C. 47
  4. D. 47.5

Question 7 of 10

values ← [3, 8, 2, 8, 5]

max ← values[1]
i ← 2
REPEAT UNTIL i > 5
{
    IF values[i] > max
    {
        max ← values[i]
    }
    i ← i + 1
}
DISPLAY(max)

What is displayed?

  1. A. 8
  2. B. 5
  3. C. 2
  4. D. 3

Question 8 of 10

Ticket sales:

Show Sold Capacity
Noon 40 50
Evening 50 50
Late 20 40
Matinee 35 40
full ← 0
FOR EACH row IN table
{
    IF row.Sold = row.Capacity
    {
        full ← full + 1
    }
}
DISPLAY(full)

What is displayed?

  1. A. 0
  2. B. 1
  3. C. 2
  4. D. 4

Question 9 of 10

A transformation replaces each Lap2 in the runs table with Lap2 - 1, then filters runners still having Lap2 ≥ 48.

Runner Lap1 Lap2 Lap3
Jia 50 48 49
Ken 47 47 46
Liv 52 51 50
Mo 49 48 48

Which runners remain after both steps?

  1. A. Jia and Liv
  2. B. Ken and Mo
  3. C. Liv only
  4. D. Jia, Liv, and Mo

Question 10 of 10

Classroom supply table:

Item Count
Markers 12
Staples 3
Tape 7
Glue 12

A search displays the first Item (top to bottom) with Count = 12. What is displayed?

  1. A. Glue
  2. B. Tape
  3. C. Staples
  4. D. Markers