An algorithm is intended to display the following output.
red red blue red red blue red red blue
Which of the following code segments can be used to display the intended output?
Comp Sci unit 3 #8
Quiz
•
Computers
•
11th Grade
•
Easy
Nick Nessralla
Used 11+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
An algorithm is intended to display the following output.
red red blue red red blue red red blue
Which of the following code segments can be used to display the intended output?
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
A flowchart provides a way to visually represent an algorithm and uses the following building blocks.
BlockExplanationOvalThe start or end of the algorithmRectangleOne or more processing steps, such as a statement that assigns a value to a variableDiamondA conditional or decision step, where execution proceeds to the side labeled true if the condition is true and to the side labeled false otherwiseParallelogramDisplays a message
In the flowchart below, assume that j and k are assigned integer values.
Which of the following initial values of j and k will cause the algorithm represented in the flowchart to result in an infinite loop?
j = -5, k = 5
j = 0, k = 5
j = 5, k = 0
j = 5, k = -5
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following program.
Which of the following describes the result of executing the program?
The program displays the sum of the even integers from 2 to 10.
The program displays the sum of the even integers from 2 to 20.
The program displays the sum of the odd integers from 1 to 9.
The program displays the sum of the odd integers from 1 to 19.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
The code segment below is intended to display all multiples of 5 between the values start and end, inclusive. For example, if start has the value 35 and end has the value 50 , the code segment should display the values 35,40 45, , and 50. Assume that start and end are multiples of 5 and that start is less thanend .
Which of the following could replace <Missing Expression> in line 2 so that the code segment works as intended?
5.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
The following code segment is intended to remove all duplicate elements in the list myList. The procedure does not work as intended.
j ← LENGTH(myList)
REPEAT UNTIL(j = 1)
{
IF(myList[j] = myList[j - 1])
{
REMOVE(myList, j)
}
j ← j - 1
}
For which of the following contents of myList will the procedure NOT produce the intended results?
Select two answers.
[10, 10, 20, 20, 10, 10]
[30, 30, 30, 10, 20, 20]
[30, 50, 40, 10, 20, 40]
[50, 50, 50, 50, 50, 50]
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
A biologist wrote a program to simulate the population of a sample of bacteria. The program uses the following procedures.
Code for the simulation is shown below.
hours ← 0
startPop ← InitialPopulation ()
currentPop ← startPop
REPEAT UNTIL ((hours ≥ 24) OR (currentPop ≤ 0))
{
currentPop ← NextPopulation (currentPop)
hours ← hours + 1
}
DISPLAY (currentPop - startPop)
Which of the following are true statements about the simulation?
-The simulation continues until either 24 hours pass or the population reaches 0.
-The simulation displays the average change in population per hour over the course of the simulation.
-The simulation displays the total population at the end of the simulation.
I only
II only
III only
I and II
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following program code.
Which of the following best describes the result of running the program code?
The number 0 is displayed.
The number 6 is displayed.
The number 10 is displayed.
Nothing is displayed; the program results in an infinite loop.
12 questions
Unit 5 Lists, Loops, & Traversals
Quiz
•
10th - 12th Grade
15 questions
AP CSP Algorithms & Programming (College Board Style)
Quiz
•
9th - 12th Grade
15 questions
Types of Software
Quiz
•
11th - 12th Grade
9 questions
Computer Science Review
Quiz
•
9th - 12th Grade
12 questions
Hour of Code
Quiz
•
6th - 12th Grade
10 questions
Arduino X-3
Quiz
•
9th - 12th Grade
15 questions
GCSE - 2.3 Producing Robust Programs
Quiz
•
9th - 11th Grade
10 questions
Comp Sci unit 3 #6
Quiz
•
11th Grade
15 questions
Character Analysis
Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
10 questions
American Flag
Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension
Quiz
•
5th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25
Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers
Quiz
•
6th - 8th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Taxes
Quiz
•
9th - 12th Grade
17 questions
Parts of Speech
Quiz
•
7th - 12th Grade
20 questions
Chapter 3 - Making a Good Impression
Quiz
•
9th - 12th Grade
20 questions
Inequalities Graphing
Quiz
•
9th - 12th Grade
10 questions
Identifying equations
Quiz
•
KG - University