Unit 4 #2

Quiz
•
Chemistry
•
12th Grade
•
Easy
Standards-aligned
Clifford Buckles
Used 7+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider two lists of numbers called list1 and list2. A programmer wants to determine how many different values appear in both lists. For example, if list1 contains [10, 10, 20, 30, 40, 50, 60] and list2 contains [20, 20, 40, 60, 80], then there are three different values that appear in both lists (20, 40, and 60).
The programmer has the following procedures available.
Which of the following can be used to assign the intended value to count ?
bothList ← Combine (list1, list2)
uniqueList ← RemoveAllDups (bothList)
count ← LENGTH (bothList) - LENGTH (uniqueList)
newList1 ← RemoveAllDups (list1)
newList2 ← RemoveAllDups (list2)
bothList ← Combine (newList1, newList2)
count ← LENGTH (list1) + LENGTH (list2) - LENGTH (bothList)
newList1 ← RemoveAllDups (list1)
newList2 ← RemoveAllDups (list2)
bothList ← Combine (newList1, newList2)
count ← LENGTH (newList1) + LENGTH (newList2) - LENGTH (bothList)
newList1 ← RemoveAllDups (list1)
newList2 ← RemoveAllDups (list2)
bothList ← Combine (newList1, newList2)
uniqueList ← RemoveAllDups (bothList)
count ← LENGTH (bothList) - LENGTH (uniqueList)
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
A computer program contains code in several places that asks a user to enter an integer within a specified range of values. The code repeats the input request if the value that the user enters is not within the specified range. A programmer would like to create a procedure that will generalize this functionality and can be used throughout the program. The correct use of the procedure is shown below, where min is the least acceptable value, max is the greatest acceptable value, and promptString is the string that should be printed to prompt the user enter a value.
inputVal ← getRange(min, max, promptString)
Which of the following is a correct implementation of the getRange procedure?
PROCEDURE getRange(min, max, promptString)
{
DISPLAY(promptString)
RETURN(INPUT())
}
PROCEDURE getRange(min, max, promptString)
{
DISPLAY(promptString)
x ← INPUT()
RETURN(x)
}
PROCEDURE getRange(min, max, promptString)
{
DISPLAY(promptString)
x ← INPUT()
REPEAT UNTIL(x ≥ min AND x ≤ max)
{
DISPLAY(promptString)
x ← INPUT()
}
}
PROCEDURE getRange(min, max, promptString)
{
DISPLAY(promptString)
x ← INPUT()
REPEAT UNTIL(x ≥ min AND x ≤ max)
{
DISPLAY(promptString)
x ← INPUT()
}
RETURN(x)
}
3.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
A program is created to perform arithmetic operations on positive and negative integers. The program contains the following incorrect procedure, which is intended to return the product of the integers and .
A programmer suspects that an error in the program is caused by this procedure. Under which of the following conditions will the procedure NOT return the correct product?
Select two answers.
When the values of x and y are both positive.
When the values of x is positive and the value of y is negative.
When the values of x is negative and the value of y is positive.
When the values of x and y are both negative.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
The following procedure is intended to return the number of times the value val appears in the list myList. The procedure does not work as intended.
Line 01: PROCEDURE countNumOccurences(myList, val)
Line 02: {
Line 03: FOR EACH item IN myList
Line 04: {
Line 05: count ← 0
Line 06: IF(item = val)
Line 07: {
Line 08: count ← count + 1
Line 09: }
Line 10: }
Line 11: RETURN(count)
Line 12: }
Which of the following changes can be made so that the procedure will work as intended?
Changing line 6 to IF(item = count)
Changing line 6 to IF(myList[item] = val)
Moving the statement in line 5 so that it appears between lines 2 and 3
Moving the statement in line 11 so that it appears between lines 9 and 10
Tags
NGSS.K-2-ETS1-1
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
A student is creating a procedure to determine whether the weather for a particular month was considered very hot. The procedure takes as input a list containing daily high temperatures for a particular month. The procedure is intended to return true if the daily high temperature was at least 90 degrees for a majority of days in the month and return false otherwise.
Which of the following can be used to replace <Missing Code> so that the procedure works as intended?
Tags
NGSS.3-ESS2-1
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
The following procedure is intended to return true if at least two of the three parameters are equal in value and is intended to return false otherwise.
PROCEDURE AnyPairs (x, y, z)
{
IF (x = y)
{
RETURN (true)
}
ELSE
{
RETURN (y = z)
}
}
For which of the following procedure calls does the procedure NOT return the intended value?
AnyPairs ("bat", "cat", "rat")
AnyPairs ("bat", "bat", "rat")
AnyPairs ("bat", "cat", "bat")
AnyPairs ("bat", "cat", "cat")
7.
MULTIPLE SELECT QUESTION
45 sec • 1 pt
The procedure NumOccurrences is intended to count and return the number of times targetWord appears in the list wordList. The procedure does not work as intended.
For which of the following code segments will the call to NumOccurrences NOT return the intended value?
Select two answers.
Create a free account and access millions of resources
Similar Resources on Quizizz
10 questions
Reversible Irreversible Reactions Catalyst Collision Theory Graph

Quiz
•
10th - 12th Grade
11 questions
ESS Test 4 (11th) 21-22

Quiz
•
1st - 12th Grade
15 questions
Chemistry Lab Safety

Quiz
•
9th - 12th Grade
10 questions
Preparing sample for analysis

Quiz
•
11th Grade - University
10 questions
Percent by Mass & Determining Chemical Formulas

Quiz
•
10th - 12th Grade
14 questions
Standard Check for Understanding

Quiz
•
10th - 12th Grade
15 questions
PT Review (CC - 2021)

Quiz
•
10th - 12th Grade
12 questions
Titration calculations

Quiz
•
11th Grade - University
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