📚 Year 7 WJEC Computer Science: Formula & Theorem Quick Reference Handbook | Year 7 WJEC 计算机:公式定理速查手册
This quick reference handbook gathers the essential formulas and theorems you will meet in Year 7 WJEC Computer Science. From binary conversions to Boolean logic and algorithm efficiency, keep these rules close when you revise or solve problems.
这本速查手册为你整理了 Year 7 WJEC 计算机课程中必备的公式与定理。无论是二进制转换、布尔逻辑还是算法效率,复习或解题时记得随时参考这些规则。
1. Binary to Decimal Conversion Formula | 二进制转十进制公式
To convert a binary number to decimal, multiply each bit by 2 raised to the power of its position, counting from 0 on the right. Add all the results together. Formula: Decimal = Σ (bit_n × 2^n)
将二进制数转换为十进制时,用每一位乘以 2 的位权次方,从右向左位权从 0 开始递增,再将所有结果相加。公式:十进制数 = Σ (第n位数字 × 2ⁿ)
Example: 1011₂ = (1×2³) + (0×2²) + (1×2¹) + (1×2⁰) = 8 + 0 + 2 + 1 = 11₁₀
举个实例:二进制 1011 转为十进制 11,这样算: (1×8)+(0×4)+(1×2)+(1×1)=11。
2. Decimal to Binary: The Division Method | 十进制转二进制:除2取余法
The systematic method is to repeatedly divide the decimal number by 2, recording the remainder each time. Read the remainders from bottom to top to get the binary equivalent. There is no single-line formula, but the process is: while number > 0, remainder = number % 2, record remainder, number = number // 2.
系统的方法是将十进制数反复除以 2,每次记录余数。从下往上读取余数,就得到对应的二进制数。虽然没有单行公式,但过程可以描述为:当数字大于 0 时,余数 = 数字 mod 2,记录余数,然后数字 = 数字整除 2。
Example: 13₁₀ → 13 ÷ 2 = 6 r 1; 6 ÷ 2 = 3 r 0; 3 ÷ 2 = 1 r 1; 1 ÷ 2 = 0 r 1 → binary: 1101₂
例如:十进制 13 转二进制:13÷2=6 余 1;6÷2=3 余 0;3÷2=1 余 1;1÷2=0 余 1,从下往上得 1101₂。
3. Binary Addition Rules | 二进制加法规则
Binary addition follows four simple rules: 0 + 0 = 0; 0 + 1 = 1; 1 + 0 = 1; 1 + 1 = 0, carry 1 to the next column. This is the foundation for arithmetic inside the CPU.
二进制加法遵循四条简单规则:0+0=0;0+1=1;1+0=1;1+1=0,并向高位进位 1。这是 CPU 内部算术运算的基础。
1 + 1 = 10₂ (which means 0, carry 1)
1+1 等于二进制 10,也就是本位写 0,进 1。
4. Boolean Logic: AND, OR, NOT Rules | 布尔逻辑:与、或、非规则
Boolean algebra uses only TRUE (1) and FALSE (0). The AND operation outputs 1 only if both inputs are 1. OR outputs 1 if at least one input is 1. NOT inverts the input: NOT 1 = 0, NOT 0 = 1. These can be seen as simple theorems.
布尔代数只使用真(1)和假(0)。与运算仅当两个输入均为 1 时才输出 1;或运算只要至少一个输入为 1 就输出 1;非运算将输入取反:非 1 得 0,非 0 得 1。这些可以视为最基本的定理。
A AND B = A · B; A OR B = A + B; NOT A = Ā
表达方式:A 与 B 记作 A·B;A 或 B 记作 A+B;非 A 记作 Ā。
5. Boolean Laws: Commutative, Associative, Distributive | 布尔代数定律:交换律、结合律、分配律
These laws let you rearrange and simplify logic expressions: Commutative – A·B = B·A, A+B = B+A. Associative – (A·B)·C = A·(B·C), (A+B)+C = A+(B+C). Distributive – A·(B+C) = (A·B)+(A·C) and A+(B·C) = (A+B)·(A+C).
这些定律可以帮助你重组和化简逻辑表达式。交换律:A·B = B·A,A+B = B+A。结合律:(A·B)·C = A·(B·C),(A+B)+C = A+(B+C)。分配律:A·(B+C) = (A·B)+(A·C),以及 A+(B·C) = (A+B)·(A+C)。
记住:布尔分配律有两种形式,第二个形式在普通代数中不成立,但在逻辑中是成立的。
6. De Morgan’s Theorems | 德摩根定理
De Morgan’s theorems are essential for simplifying negated expressions: NOT (A AND B) = (NOT A) OR (NOT B); NOT (A OR B) = (NOT A) AND (NOT B). Symbolically: (A·B)′ = A′ + B′; (A+B)′ = A′·B′.
德摩根定理是化简取反表达式的关键:非(A 与 B)等于非 A 或非 B;非(A 或 B)等于非 A 与非 B。符号表示为:(A·B)′ = A′+B′;(A+B)′ = A′·B′。
Example: (A·B)′ = A′ + B′
比如一个很简单的情形:如果 A=1, B=0,那么 A·B=0,取反为1;而 A′+B′ = 0+1=1,结果一致。
7. Logic Gate Symbols and Truth Tables | 逻辑门符号与真值表
Each Boolean operation has a standard gate symbol. The basic gate set: AND (D-shaped), OR (curved arrow shape), NOT (triangle with a bubble). Truth tables list all possible input combinations and the output. There is no single theorem, but every gate follows the Boolean rules above.
每种布尔运算都有标准的逻辑门符号。基本门包括:与门(D 形状)、或门(弯曲箭头形状)、非门(带小圆圈的三角形)。真值表列出所有可能的输入组合及其对应输出。虽然这里没有单独的定理,但每个门都遵循前面提到的布尔规则。
快速记忆:与门像半圆加平底,或门像尖盾,非门是一个三角形加小圈。
8. Data Unit Conversion Formulas | 数据单位转换公式
Storage size is measured in bits, bytes, kilobytes, megabytes, and so on. The base conversion is always powers of 2 in this subject: 1 byte = 8 bits; 1 KB = 1024 bytes; 1 MB = 1024 KB; 1 GB = 1024 MB. Formula: number in larger unit = number in smaller unit / 1024 (or × 1024 in reverse).
存储大小以位、字节、千字节、兆字节等为单位。在本课程中,换算始终基于 2 的次方:1 字节 = 8 位;1 KB = 1024 字节;1 MB = 1024 KB;1 GB = 1024 MB。公式:较大单位的数值 = 较小单位的数值 ÷ 1024(反过来则乘 1024)。
For example: 2048 MB = 2048 / 1024 = 2 GB
比如:2048 MB 除以 1024 等于 2 GB。
9. Image File Size Estimation | 图像文件大小估算
Uncompressed image size can be estimated with: Size (in bits) = width in pixels × height in pixels × colour depth (bits per pixel). To get bytes, divide by 8. This is a key formula when discussing bitmap images.
未压缩图像的文件大小可以用公式估算:大小(位) = 图像宽度像素数 × 高度像素数 × 色彩深度(每像素位数)。要得到字节数,再除以 8。这讨论位图图像时的一个关键公式。
Example: 100×100 pixels, 24-bit colour → 100×100×24 = 240,000 bits ≈ 30,000 bytes (approx 29.3 KB)
实例:100×100 像素,24 位色彩,大小为 100×100×24 = 240,000 位,约为 30,000 字节(大约 29.3 KB)。
10. Sound File Size: Sampling Theorem Related Formula | 声音文件大小:采样定理相关公式
For uncompressed audio, the formula is: Size (bits) = sample rate (Hz) × bit depth × number of channels × duration (seconds). This comes from the concept of sampling audio signals to convert them into digital data.
对于未压缩音频,公式为:大小(位) = 采样率(Hz) × 位深度 × 声道数 × 时长(秒)。这个公式源自将音频信号采样并转化为数字数据的概念。
CD quality: 44,100 Hz × 16 bits × 2 channels × 1 second = 1,411,200 bits ≈ 176.4 KB per second
CD 音质:44,100 Hz × 16 位 × 2 声道 × 1 秒 = 1,411,200 位,约每秒 176.4 KB。
11. Linear Search vs Binary Search Comparison Count | 线性搜索与二分搜索比较次数
In the worst case, linear search through a list of n items takes n comparisons. Binary search on a sorted list of n items takes at most ⌊log₂(n)⌋ + 1 comparisons. This is not a single formula but a bounding theorem for algorithm efficiency.
在最坏情况下,对一个包含 n 个元素的列表进行线性搜索需要 n 次比较。在一个有序列表上进行二分搜索,最多需要 ⌊log₂(n)⌋ + 1 次比较。这不是单一公式,而是算法效率的界定理。
For n=1000: linear = 1000 comparisons; binary ≈ log₂(1000) + 1 ≈ 10+1=11 comparisons
当 n=1000 时:线性搜索 1000 次比较,二分搜索约 10+1=11 次比较。
12. Caesar Cipher Shift Formula | 凯撒密码移位公式
A Caesar cipher shifts each letter by a fixed number k. For encryption: E(x) = (x + k) mod 26, where x is the position of the letter (A=0, B=1, …). Decryption: D(x) = (x – k) mod 26. This is a basic encryption theorem.
凯撒密码将每个字母向后移动固定位数 k。加密公式:E(x) = (x + k) mod 26,其中 x 是字母的位置(A=0, B=1…)。解密公式:D(x) = (x – k) mod 26。这是基础的加密定理。
Example with k=3: A (0) → (0+3) mod 26 = 3 → D; X (23) → (23-3) mod 26 = 20 → U
k=3 的例子:A (0) 加密成 (0+3) mod 26 = 3 即 D;X (23) 解密成 (23-3) mod 26 = 20 即 U。
Published by TutorHao | Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导