← Course Hub← 课程主页 ← All Units← 返回单元列表
H I G H  S C H O O L  C O M P U T E R  S C I E N C E
Practice练习题

Boolean Logic and Number Systems布尔逻辑与数制

Practice Questions · AP CSP-Feeder · US / ON / BC / AB Styles练习题集 · AP CSP 衔接 · 美 / 安 / 卑 / 阿省风格

EASY MEDIUM HARD 🇺🇸 US 🇨🇦 ON 🇨🇦 BC 🇨🇦 AB AP CSP-style MCQAP CSP 风格选择题 AP CSP-feeder FRQAP CSP 衔接简答题 ON Provincial-style安大略省考风格 BC Provincial-style卑诗省考风格 AB/Universal Applied阿省/通用应用题 Honors荣誉级


Name:姓名:Date:日期:
PART I  ·  SHORT RESPONSE第一部分  ·  短答题AP CSP-style MCQ + ON/BC short answer · 25 marksAP CSP 风格选择题 + 安/卑省考短答 · 共 25 分

Section A · Short ResponseA 部分 · 短答题

Questions mix multiple-choice and short-answer items. For MCQs, circle the letter and show your working in the space provided. For short-answer items, write exact values. Use binary notation (e.g. 1010), hex notation (e.g. 0xFF), and truth-table notation (T/F or 0/1) as directed. Do not use a calculator.本部分包含选择题与短答题。选择题请圈出字母,并在答题空白处写出计算过程。短答题写出精确值。按题目要求使用二进制(如 1010)、十六进制(如 0xFF)或真值表(T/F 或 0/1)表示法。无需计算器。

Q1 EASY 🇺🇸 US AP CSP-style MCQAP CSP 风格选择题 §1 Binary Number System二进制数制 · AP CSP DAT-1.A [3 marks][3 分]

What is the decimal value of the 8-bit binary number 00110110?8 位二进制数 00110110 的十进制值是多少?

  1. (A) 4444
  2. (B) 5454
  3. (C) 3838
  4. (D) 4848
Q2 EASY 🇺🇸 US AP CSP-style MCQAP CSP 风格选择题 §2 Hexadecimal十六进制 · CSTA 3A-DA-09 [3 marks][3 分]

How many bits does a single hexadecimal digit represent, and what is the decimal value of the hex digit D?一个十六进制位代表多少二进制位?十六进制数字 D 的十进制值是多少?

  1. (A) 4 bits; D = 124 位;D = 12
  2. (B) 8 bits; D = 138 位;D = 13
  3. (C) 4 bits; D = 134 位;D = 13
  4. (D) 4 bits; D = 144 位;D = 14
Q3 MEDIUM 🇨🇦 ON ON Provincial-style安大略省考风格 §3 Converting Between Bases进制转换 · ON ICS3U A1.2 [5 marks][5 分]

Convert decimal 109 to binary using repeated division by 2. Show each division step.用反复除以 2 的方法将十进制 109 转换为二进制。写出每一步除法。

(a) Show the full division table (dividend, divisor, quotient, remainder for each step).写出完整除法表(每步的被除数、除数、商、余数)。 [3]
(b) State the 8-bit binary result (pad with leading zeros if needed).写出 8 位二进制结果(如需要请在高位补零)。 [1]
(c) Verify your answer by converting the binary result back to decimal using a place-value table.用位权表将二进制结果转回十进制,验证你的答案。 [1]
Q4 MEDIUM 🇨🇦 BC BC Provincial-style卑诗省考风格 §4 Binary Arithmetic二进制算术 · AP CSP DAT-1.B [6 marks][6 分]

Add the following two 4-bit binary numbers. Show your carry row.将以下两个 4 位二进制数相加,写出进位行。

  0 1 1 1
+ 0 1 0 1
(a) Complete the carry-row addition table below, then state the 5-bit result.补全进位行加法表,然后写出 5 位结果。 [3]
Bit position位位置3210
Carry in进位输入0
Sum bit和位
Carry out进位输出
(b) Verify your result by converting both operands and the sum to decimal.将两个操作数和结果转换为十进制以验证。 [1]
(c) If the result must fit in exactly 4 bits, what problem occurs? Name this phenomenon.如果结果必须存储在 4 位中,会发生什么问题?写出这种现象的名称。 [2]
Q5 MEDIUM 🇨🇦 AB AB/Universal Applied阿省/通用应用题 §5 Representing Text and Data文本与数据表示 · AB CSE2130 1.1.2 [8 marks][8 分]

Use the following ASCII anchor values: 'A' = 65, 'a' = 97, '0' = 48. Letters are consecutive (e.g. 'B' = 66).使用以下 ASCII 锚点值:'A' = 65'a' = 97'0' = 48。字母连续(如 'B' = 66)。

(a) State the ASCII decimal code for each character: 'C', 'm', '3'.写出以下字符的 ASCII 十进制码:'C''m''3' [3]
(b) A program stores the two-character string "Hi" ('H' = 72, 'i' = 105) in memory. State (i) the total number of bytes used and (ii) the 8-bit binary representation of 'H'.程序将双字符字符串 "Hi"'H' = 72'i' = 105)存入内存。写出 (i) 共使用的字节数,以及 (ii) 'H' 的 8 位二进制表示。 [3]
(c) Explain in one sentence why ASCII cannot encode the Chinese character 中, and name the encoding standard that can.用一句话解释为什么 ASCII 无法编码汉字"中",并写出能编码该字符的编码标准名称。 [2]
PART II  ·  EXTENDED RESPONSE第二部分  ·  简答题AP CSP-feeder FRQ + Honors · 30 marksAP CSP 衔接简答题 + 荣誉级 · 共 30 分

Section B · Extended ResponseB 部分 · 简答题

Show every step of your working. For truth tables, fill in every cell; for conversions, show the intermediate steps. For justify questions, two sentences of reasoning earn full marks. Do not use a calculator.写出每一步过程。真值表须填写每一格;进制转换须写出中间步骤。论证题两句推理即可满分。无需计算器。

Q6 EASY 🇺🇸 US AP CSP-feeder FRQAP CSP 衔接简答题 §6 Boolean Logic布尔逻辑 · ON ICS3U A1.4 [4 marks][4 分]

Complete the truth table for the three Boolean operators AND, OR, and NOT. Use T and F.补全 AND、OR 和 NOT 三个布尔运算符的真值表。使用 T 和 F。

ABA AND BA OR BNOT A
TT
TF
FT
FF
(a) Fill in all 12 cells of the truth table above.补全上方真值表中全部 12 个格子。 [3]
(b) Using the table, explain in one sentence when AND produces a TRUE result.根据真值表,用一句话解释 AND 在什么情况下产生 TRUE 结果。 [1]
Q7 MEDIUM 🇨🇦 ON 🇨🇦 BC ON Provincial-style安大略省考风格 §2 + §3 Hex and Base Conversion十六进制与进制转换 · ON ICS3U A1.2 / CSTA 3A-DA-09 [8 marks][8 分]

A web designer uses the HTML color code #B43C00 for a heading colour.一位网页设计师对标题颜色使用 HTML 颜色代码 #B43C00

(a) State the three hex pairs (R, G, B) of the color code and identify which channel is strongest (has the highest decimal value). Show your conversion from hex to decimal for each pair.写出颜色代码的三个十六进制对(R、G、B),并指出哪个通道最强(十进制值最大)。写出每对的十六进制到十进制转换过程。 [3]
(b) Convert the Red byte 0xB4 to 8-bit binary using the nibble method (group each hex digit into 4 bits).用半字节方法(每个十六进制位展开为 4 位)将红色字节 0xB4 转换为 8 位二进制。 [2]
(c) The designer wants to convert decimal 200 to hex to use as a new blue value. Show the repeated-division method and give the hex result.设计师想将十进制 200 转换为十六进制作为新的蓝色值。展示反复除以 16 的方法并给出十六进制结果。 [2]
(d) Explain in one sentence why hex is preferred over binary for representing color codes in HTML.用一句话解释为什么在 HTML 中表示颜色代码时更倾向于使用十六进制而非二进制。 [1]
Q8 MEDIUM 🇺🇸 US AP CSP-feeder FRQAP CSP 衔接简答题 §4 Binary Arithmetic + Overflow二进制算术与溢出 · AP CSP DAT-1.B [8 marks][8 分]

A system stores integers using exactly 4 bits. Consider the following two addition problems.某系统用恰好 4 位存储整数。考察以下两道加法题。

Problem A:   0011 + 0100     (decimal 3 + 4)
Problem B:   1101 + 0111     (decimal 13 + 7)
(a) Perform Problem A in binary. Show the carry row. State the 4-bit result and its decimal value.用二进制计算问题 A。写出进位行,写出 4 位结果及其十进制值。 [3]
(b) Perform Problem B in binary. Show the carry row. State all bits produced (including any carry-out beyond bit 3).用二进制计算问题 B。写出进位行,写出产生的全部位(包括超出第 3 位的进位输出)。 [3]
(c) For Problem B, state the 4-bit stored result and its decimal value. Explain why this result is incorrect and name the error type.对于问题 B,写出存储的 4 位结果及其十进制值。解释为什么这个结果是错误的,并写出错误类型的名称。 [2]
Q9 HARD Honors荣誉级 🇺🇸 US AP CSP-feeder FRQAP CSP 衔接简答题 §6 + §7 Compound Boolean + De Morgan's Laws复合布尔 + 德摩根定律 · CSTA 3B-CS-02 [10 marks][10 分]

Consider the Boolean expression: Output = (NOT A) AND (B OR C).考察布尔表达式:Output = (NOT A) AND (B OR C)

(a) Build the complete truth table for this expression with three inputs A, B, C. Add intermediate columns for NOT A and B OR C. Use 0/1 notation.为该表达式的三个输入 A、B、C 建立完整真值表。添加 NOT A 和 B OR C 的中间列。使用 0/1 表示法。 [5]
ABCNOT AB OR COutput输出
000
001
010
011
100
101
110
111
(b) State how many of the 8 input combinations produce an Output of 1.写出 8 种输入组合中有多少种产生输出 1。 [1]
(c) De Morgan's first law states: NOT (A AND B) = (NOT A) OR (NOT B). Apply this law to simplify NOT ((NOT A) AND (B OR C)) into an equivalent expression. Show each step.德摩根第一定律:NOT (A AND B) = (NOT A) OR (NOT B)。应用该定律将 NOT ((NOT A) AND (B OR C)) 化简为等价表达式。写出每一步。 [3]
(d) In Python, the expression (NOT A) AND (B OR C) is written using the operators not, and, or. Rewrite this expression in valid Python syntax for Boolean variables.在 Python 中,表达式 (NOT A) AND (B OR C) 用运算符 notandor 书写。用有效的 Python 语法为布尔变量改写此表达式。 [1]
PART III  ·  MODELING / APPLIED第三部分  ·  建模与应用Universal / multi-region applied · 25 marks通用/多地区应用题 · 共 25 分

Section C · Modeling and ApplicationsC 部分 · 建模与应用

Read each scenario carefully. Show all conversion steps and truth-table fills. For Python snippets, show correct indentation. Conclude each question with a one-sentence summary answer.仔细阅读每个场景后再动笔。写出所有转换步骤和真值表填写过程。Python 代码须正确缩进。每题以一句完整的总结句作答。

Q10 MEDIUM 🇺🇸 US 🇨🇦 ON AP CSP-feeder FRQAP CSP 衔接简答题 §7 Logic Gates and Truth Tables逻辑门与真值表 · CSTA 3B-CS-02 [8 marks][8 分]

A circuit computes the output: Out = (A AND B) OR (NOT A). All values use 0/1 notation.某电路计算输出:Out = (A AND B) OR (NOT A)。所有值使用 0/1 表示法。

(a) Complete the truth table below. Add intermediate columns for A AND B and NOT A.补全以下真值表,添加 A AND B 和 NOT A 的中间列。 [4]
ABA AND BNOT AOut输出
00
01
10
11
(b) How many rows have Out = 1? State each (A, B) pair that produces Out = 1.有多少行的输出 Out = 1?写出每个产生 Out = 1 的 (A, B) 对。 [2]
(c) When A = 1, describe in one sentence how the circuit simplifies (hint: look at what NOT A becomes and what that means for the OR).当 A = 1 时,用一句话描述该电路如何化简(提示:看 NOT A 变成什么,以及这对 OR 意味着什么)。 [1]
(d) A NAND gate outputs 0 only when both inputs are 1 (otherwise 1). What is the output of a NAND gate when A = 1 and B = 0?NAND 门只有当两个输入都为 1 时输出 0(其他情况输出 1)。当 A = 1、B = 0 时,NAND 门的输出是什么? [1]
Q11 MEDIUM 🇨🇦 BC 🇨🇦 AB BC Provincial-style卑诗省考风格 §5 + §6 ASCII + Boolean in codeASCII + 代码中的布尔逻辑 · AB CSE1120 / BC CS11 [9 marks][9 分]

A program checks whether a character is an uppercase ASCII letter (A-Z) using Boolean logic. 'A' = 65, 'Z' = 90.某程序使用布尔逻辑检查字符是否为大写 ASCII 字母(A-Z)。'A' = 65'Z' = 90

code = ord(ch)              # ord() returns the ASCII decimal code
is_upper = code >= 65 and code <= 90
(a) Evaluate is_upper for each of these three characters: 'M' (77), 'z' (122), '3' (51). Show whether each condition (code >= 65 and code <= 90) is True or False, then give is_upper.对以下三个字符求 is_upper 的值:'M'(77)、'z'(122)、'3'(51)。分别写出 code >= 65code <= 90 的真假,再给出 is_upper [3]
(b) A second program also needs to check whether the character is a digit (0-9; ASCII 48-57). Write a single Python Boolean expression is_upper_or_digit that is True if the character is an uppercase letter OR a digit.第二个程序还需要检查字符是否为数字(0-9;ASCII 48-57)。写一个 Python 布尔表达式 is_upper_or_digit,若字符为大写字母或数字则为 True。 [3]
(c) Using De Morgan's law, write an equivalent expression for not is_upper_or_digit (i.e. the character is neither an uppercase letter nor a digit) without using not on the whole expression.使用德摩根定律,写出 not is_upper_or_digit(即字符既不是大写字母也不是数字)的等价表达式,且不对整体使用 not [3]
Q12 HARD 🇺🇸 US 🇨🇦 ON 🇨🇦 BC AP CSP-feeder FRQAP CSP 衔接简答题 §1 + §3 + §4 + §7 Bits, Conversion, Arithmetic, Gates位、转换、算术、逻辑门 · AP CSP DAT-1 / CSTA 3A-DA-09 [8 marks][8 分]

A simple 4-bit computer uses binary arithmetic and logic gates in its ALU (Arithmetic Logic Unit). Answer the questions below about a specific operation.一台简单的 4 位计算机在其 ALU(算术逻辑单元)中使用二进制算术和逻辑门。回答以下关于某具体运算的问题。

Input registers: A = 0b1001   (decimal 9)
                 B = 0b0110   (decimal 6)
Operation: OUT = A AND B    (bitwise: compare each bit position)
Bitwise AND:
  A: 1 0 0 1
  B: 0 1 1 0
  ─────────
OUT: ? ? ? ?
(a) Complete the bitwise AND operation above. State the 4-bit binary result and its decimal value.完成上方的按位 AND 运算。写出 4 位二进制结果及其十进制值。 [2]
(b) Now compute A OR B bitwise. State the 4-bit binary result and convert it to hexadecimal.现在按位计算 A OR B。写出 4 位二进制结果并将其转换为十六进制。 [2]
(c) The ALU now adds A + B in binary. Show the carry row and state the full 5-bit result. Then explain what happens to the result if the ALU can only store 4 bits.ALU 现在进行二进制 A + B 加法。写出进位行并写出完整的 5 位结果,然后解释如果 ALU 只能存储 4 位会发生什么。 [3]
(d) How many distinct values can this 4-bit computer represent in one register? State the minimum and maximum unsigned values it can store.这台 4 位计算机的一个寄存器可以表示多少个不同的值?写出它能存储的无符号数的最小值和最大值。 [1]

🇺🇸 US CSTA / AP CSP美国 CSTA / AP CSP3A-DA-09 · 3B-CS-02 · DAT-1.A/B
🇨🇦 Ontario安大略ICS3U A1.2 · A1.4 · CSE2130
🇨🇦 British Columbia不列颠哥伦比亚CS 10/11: binary, hex, Boolean operators, logic gatesCS 10/11:二进制、十六进制、布尔运算符、逻辑门
🇨🇦 Alberta阿尔伯塔CSE1120: outcome 2.6; CSE2130: 1.1.2 (ASCII/Unicode)CSE1120:结果 2.6;CSE2130:1.1.2(ASCII/Unicode)

Full Syllabus Map in Study Guide: ../Study Guides/Unit_9_Boolean_Logic_and_Number_Systems.html. CS has no AB standalone diploma exam; AB framing uses CSE1120/CSE2130 outcomes.完整大纲对照见学习指南:../Study Guides/Unit_9_Boolean_Logic_and_Number_Systems.html。CS 无独立 AB 毕业考;AB 题使用 CSE1120/CSE2130 结果框架。