Skip to content

平成27年度 春期 ITパスポート試験 問97

This question's explanation and your answers so far.

問97
頻出度★★☆

F社では,新製品を開発するに当たり,100人のモニタを募集して市場調査を行った。モニタには,性能,価格,デザインの三つの項目について,それぞれを重視するかどうかを“はい”又は“いいえ”のいずれかで答えてもらった。 モニタから得られた回答は,図1のレコード形式で回答ファイルに登録した。 レコードの項目“性能”,“価格”,“デザイン”には,それぞれ,質問に対する回答が“はい”の場合には1が,“いいえ”の場合には0が記録されている。 回答ファイルの中から,条件に合致するレコード数を表示するために,次の命令が使用できる。 件数表示(条件) ここで,条件には,and,or及び[ ]を組み合わせた複合条件を指定できる。条件の評価は[ ]の中が優先して評価される。また,[ ]の中にさらに[ ]を記述することもできる。 条件を変えて,命令を実行した結果を表1に示す。 表1 命令を実行した結果

条件件数表示命令の実行結果
性能=155
価格=160
デザイン=145
[性能=1]and[価格=1]30
[価格=1]and[デザイン=1]25

次の命令を実行したときに表示されるレコード数は,どのような条件に合致する人数を表しているか。 件数表示([性能=1] and [デザイン=0])

出典 平成27年度 春期 ITパスポート試験 問97
解説

問 97

  • Incorrectア

    If you wanted to count the people who “value both performance and design”, the condition would have to be “Count display ([Performance=1] and [Design=1])”, with a 1 on the design side as well. In this question's command the design side is =0, that is, “does not value design” is the condition, so people who value design are excluded from the extraction to begin with. This wrong answer grasps the meaning of and correctly, but you can end up choosing it if you overlook the difference between =1 and =0 (affirmation versus negation).

  • イ

    正解 The correct answer is “イ The number of monitors who value performance but do not value design”. The command “Count display ([Performance=1] and [Design=0])” counts only the records that match the condition expression and displays how many there are. Here each monitor's answer is recorded as a binary value, “values it = 1, does not value it = 0”, so [Performance=1] expresses the condition “values performance” and [Design=0] expresses the condition “does not value design”. The and (logical AND) that joins them is an operation that keeps only those records satisfying both conditions at the same time, so what gets extracted is only the records of monitors who value performance and at the same time do not value design. In terms of sets, this is the intersection of the set of people who value performance with the complement of the set of people who value design (that is, the set of people who do not value design). Therefore the number of records displayed represents the number of monitors who value performance and do not value design. There are two key points: and narrows down the selection (both conditions must hold), and “=0” means negation (NOT valuing it = not valuing it).

  • Incorrectウ

    The relation in which just one of the conditions needs to hold — “values either one of them” — is expressed by or (logical OR), not by and. The and used in this question's command is logical AND, which narrows the selection down to only those records where both conditions hold at the same time. If you mix up and with or, the set extracted becomes the union (a wider range) instead of the intersection (a narrower range), and the meaning changes completely, so be careful. Strictly speaking, “exactly one of the two” corresponds to the idea of exclusive OR (XOR), which is likewise different from the and in this question.

  • Incorrectエ

    If you wanted to count the people who “value neither performance nor design”, the condition would have to be “Count display ([Performance=0] and [Design=0])”, with a 0 on the performance side as well. In this question's command the performance side is =1, that is, “values performance” is the condition, so people who do not value performance are not extracted. This wrong answer is easy to pick if you look at only one of the two conditions and jump to the conclusion “there is a =0, so both must be negated”; a condition expression must be checked item by item for its value.

ここがポイント
  • The logical operation and (logical AND) narrows the selection down to only those records that satisfy both conditions at the same time; in terms of sets it corresponds to the intersection. On the other hand, or (logical OR) means “satisfying either one is enough” = the union. When reading the meaning of a condition expression, telling and apart from or is the single most important point.
  • In data where answers are encoded as binary values such as “values it = 1, does not value it = 0”, [Item=1] expresses affirmation and [Item=0] expresses negation (NOT). You can avoid misreading a condition expression by reading it in this order: first check one by one whether each item is 1 or 0, and only then look at the logical operator that joins them.
用語

Your answers