39. If a programmer tested the following code with the values indicated, would the program cor- rectly calculate the average of the test scores? Assume all variables and lists have been appro- priately initialized. FOR EACH score IN testScores { IF score> 0 ( total total } count count 1 } DISPLAY ("The average score on the test was: ", total / count) 80, 85, 50, 0, Test1 [100, 90, 80, 85, 90) Test2 [192, 85, 74, 100, 96, 88] score (A) Yes, the code works as it should for both test cases. (B) No, the code does not average the test scores correctly for either test. (C) No, the code only works for the Testl scores. (D) No, the code only works for the Test2 scores. 40. When should a heuristic algorithm be used? (A) When a problem is unable to process in reasonable time but a "close enough" solu- tion is acceptable (B) When the data is not sorted and cannot be placed in the order needed (C) When a problem is undecidable because not enough information is known (D) When searching is needed but efficiency is a requirement 41. How many times do FOR EACH loops run with lists? (A) Once (B) Until the index for the list is 0 (C) For the LENGTH of the list (D) Until the user types STOP

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Please answer this questions explain and show work please
39. If a programmer tested the following code with
the values indicated, would the program cor-
rectly calculate the average of the test scores?
Assume all variables and lists have been appro-
priately initialized.
FOR EACH score IN testScores
{
IF score>0
(
}
total total score
count count 1
DISPLAY ("The average score on
the test was: ", total / count)
Test1 [100, 90, 80, 80, 85, 50, 0,
85, 90)
Test2 [192, 85, 74, 100, 96, 881
(A) Yes, the code works as it should for both
test cases.
(B) No, the code does not average the test
scores correctly for either test.
(C) No, the code only works for the Testl
scores.
(D) No, the code only works for the Test2
scores.
40. When should a heuristic algorithm be used?
(A) When a problem is unable to process in
reasonable time but a "close enough" solu-
tion is acceptable
(B) When the data is not sorted and cannot be
placed in the order needed
(C) When a problem is undecidable because
not enough information is known
(D) When searching is needed but efficiency is
a requirement
41. How many times do FOR EACH loops run
with lists?
(A) Once
(B) Until the index for the list is 0
(C) For the LENGTH of the list
(D) Until the user types STOP
Transcribed Image Text:39. If a programmer tested the following code with the values indicated, would the program cor- rectly calculate the average of the test scores? Assume all variables and lists have been appro- priately initialized. FOR EACH score IN testScores { IF score>0 ( } total total score count count 1 DISPLAY ("The average score on the test was: ", total / count) Test1 [100, 90, 80, 80, 85, 50, 0, 85, 90) Test2 [192, 85, 74, 100, 96, 881 (A) Yes, the code works as it should for both test cases. (B) No, the code does not average the test scores correctly for either test. (C) No, the code only works for the Testl scores. (D) No, the code only works for the Test2 scores. 40. When should a heuristic algorithm be used? (A) When a problem is unable to process in reasonable time but a "close enough" solu- tion is acceptable (B) When the data is not sorted and cannot be placed in the order needed (C) When a problem is undecidable because not enough information is known (D) When searching is needed but efficiency is a requirement 41. How many times do FOR EACH loops run with lists? (A) Once (B) Until the index for the list is 0 (C) For the LENGTH of the list (D) Until the user types STOP
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps

Blurred answer
Knowledge Booster
List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education