What is displayed as a result of executing the code segment?

Unit 5 code.org Review

Quiz
•
Computers
•
11th Grade
•
Hard
Ms Seccafico
Used 148+ times
FREE Resource
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
1 3 5
5 3 1
100 300 500
500 300 100
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Shoppers at a mall were asked whether they preferred wearing gloves or mittens in cold weather. Shoppers’ preferences were stored in the list voteList as strings, with the string "Gloves" representing a preference for gloves and the string "Mittens" representing a preference for mittens.
The following code segment is intended to traverse the list and display the number of shoppers who chose gloves and the number of shoppers who chose mittens.
numGlovesVotes ←0
numMittensVotes ← 0
<MISSING CODE>
{
IF(vote = "Gloves")
{
numGlovesVotes ← numGlovesVotes + 1
}
ELSE
{
numMittensVotes ← numMittensVotes + 1
}
}
DISPLAY(numGlovesVotes)
DISPLAY(" shoppers chose gloves and")
DISPLAY(numMittensVotes)
DISPLAY(" shoppers chose mittens.")
Which of the following should replace <MISSING CODE> so that the code segment works as intended?
IF(vote ≤ LENGTH(voteList))
FOR EACH vote IN voteList
REPEAT LENGTH(voteList) TIMES
REPEAT UNTIL(vote > LENGTH(voteList))
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Consider the following code segment. Assume that index1 is a number between 1 and LENGTH(theList), inclusive, and index2 is a number between 2 and LENGTH(theList) - 1, inclusive.
theList ← [9, -1, 5, 2, 4, 8]
x ← theList[index1] + theList[index2]
What is the largest possible value that the variable x can have after the code segment executes?
17
14
11
4
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Consider the following code segment, which is intended to store ten consecutive even integers, beginning with 2, in the list evenList. Assume that evenList is initially empty.
i ← 1
REPEAT 10 TIMES
{
<MISSING CODE>
}
Which of the following can be used to replace <MISSING CODE> so that the code segment works as intended?
APPEND(evenList, i)
i ← i + 2
i ← i + 2
APPEND(evenList, i)
APPEND(evenList, 2 * i)
i ← i + 1
i ← i + 1
APPEND(evenList, 2 * i)
5.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
A teacher stores the most recent quiz scores for her class in the list scores. The first element in the list holds the maximum possible number of points that can be awarded on the quiz, and each remaining element holds one student’s quiz score. Assume that scores contains at least two elements. Which of the following code segments will set the variable found to true if at least one student scored the maximum possible number of points on the quiz and will set found to false otherwise?
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Consider the following code segment.
theList ← [-2, -1, 0, 1, 2]
count1 ← 0
count2 ← 0
FOR EACH value IN theList
{
IF(value > 0)
{
count1 ← count1 + 1
}
ELSE
{
count2 ← count2 + 1
}
}
What are the values of count1 and count2 as a result of executing the code segment?
count1 = 2, count2 = 2
count1 = 2, count2 = 3
count1 = 3, count2 = 2
count1 = 5, count2 = 0
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Assume that both lists and strings are indexed starting with index 1.
The list wordList has the following contents.
["abc", "def", "ghi", "jkl"]
Let myWord be the element at index 3 of wordList. Let myChar be the character at index 2 of myWord. What is the value of myChar ?
"e"
"f"
"h"
"i"
Create a free account and access millions of resources
Similar Resources on Quizizz
12 questions
Java Strings

Quiz
•
9th - 12th Grade
15 questions
AQA Computer Science GCSE - 3.1 Fundamentals of algorithms

Quiz
•
10th - 12th Grade
10 questions
Comp Sci unit 3 #6

Quiz
•
11th Grade
10 questions
Java Code Tracing Practice A

Quiz
•
9th - 12th Grade
16 questions
CSA Unit 3 Review

Quiz
•
10th - 12th Grade
20 questions
Programming Fundamentals Part 2

Quiz
•
9th - 11th Grade
19 questions
Traversal & String Method Review

Quiz
•
9th - 12th Grade
10 questions
String Methods

Quiz
•
9th - 12th Grade
Popular Resources on Quizizz
15 questions
Multiplication Facts

Quiz
•
4th Grade
20 questions
Math Review - Grade 6

Quiz
•
6th Grade
20 questions
math review

Quiz
•
4th Grade
5 questions
capitalization in sentences

Quiz
•
5th - 8th Grade
10 questions
Juneteenth History and Significance

Interactive video
•
5th - 8th Grade
15 questions
Adding and Subtracting Fractions

Quiz
•
5th Grade
10 questions
R2H Day One Internship Expectation Review Guidelines

Quiz
•
Professional Development
12 questions
Dividing Fractions

Quiz
•
6th Grade