Questions
(72ab92) AP CS Principles (72ab92) AP 计算机科学原理 1.2 AP-Style MC Practice 1.2 AP 风格的 MC 练习
Single choice
Consider the following two implementations of the same algorithm, each written in a different language. 考虑以下同一算法的两种实现,每种实现都使用不同的语言编写。 Language A: 语言 A: Calculate the average daily rainfall for the week (averageRainfall) by adding together the rainfall totals for each of the 7 days of the week (sun, mon, tue, wed, thu, fri, and sat) and dividing the sum by 7. 将一周 7 天(周日、周一、周二、周三、周四、周五和周六)每天的降雨量总数相加,然后将总和除以 7,计算出一周的平均每日降雨量(平均降雨量)。 Language B: 语言 B: Take the total amount of rain from each day of the week (sunday, monday, tuesday, wednesday, thursday, friday and saturday) and then average them together to get the average daily rainfall for the week (averageRainfall). 计算一周中每天(星期日、星期一、星期二、星期三、星期四、星期五和星期六)的总降雨量,然后将其平均,得到该周的平均每日降雨量(平均降雨量)。 Which of the following statements about these two implementations is true? 以下关于这两种实现的说法中哪一项是正确的?
Options
A.Language A is ambiguous because it is unclear what sun, mon, tue, wed, thu, fri, and sat refer to in context with the problem.
语言 A 具有歧义,因为不清楚 sun、mon、tue、wed、thu、fri 和 sat 在问题上下文中指的是什么。
B.Language B is ambiguous because the process of “average” is not explained well
语言 B 有歧义,因为“平均”的过程没有得到很好的解释
C.The algorithms in both languages are ambiguous because they do not specify the actual values of the seven daily rainfall totals.
这两种语言的算法都比较模糊,因为它们没有指定七天降雨总量的实际值。
D.Neither of these languages is clear enough that a programmer could write a correct solution in a high-level programming language.
这两种语言都不够清晰,程序员无法用高级编程语言编写出正确的解决方案。
View Explanation
Verified Answer
Please login to view
Step-by-Step Analysis
First, restating the scenario helps frame the evaluation: we have two algorithmic implementations described in different languages that compute the average daily rainfall over a week. The question asks which statement about these implementations is true.
Option 1: Language A is ambiguous because it is unclear what sun, mon, tue, wed, thu, fri, and sat refer to in context with the problem.
- This claim focuses on the identifiers for the days in Language A. The description explicitly mentions seven days (sun, mon, tue, wed, thu, fri, sat) as the quantities to be summed, so the intent is clear: these are the daily rainfall totals for each day of the week. The idea of summing these seven values and dividing by 7 to get an average is a standard, wel......Login to view full explanationLog in for full answers
We've collected over 50,000 authentic exam questions and detailed explanations from around the globe. Log in now and get instant access to the answers!
Similar Questions
In a consumer society, many adults channel creativity into buying things
Economic stress and unpredictable times have resulted in a booming industry for self-help products
People born without creativity never can develop it
A product has a selling price of $20, a contribution margin ratio of 40% and fixed cost of $120,000. To make a profit of $30,000. The number of units that must be sold is: Type the number without $ and a comma. Eg: 20000
More Practical Tools for Students Powered by AI Study Helper
Making Your Study Simpler
Join us and instantly unlock extensive past papers & exclusive solutions to get a head start on your studies!