📘 Unit 6 (9.
6) – Full Revision Notes
🧩 1. Writing Python Code from a Flowchart
🔹 Definition:
A flowchart visually represents a program’s steps using symbols.
🔧 How to Use:
● Oval: Start/End → e.g. Start
● Rectangle: Process → e.g. x = 5
● Diamond: Decision → e.g. if x > 10:
● Arrow: Control flow (direction of execution)
🖥️ Python Example:
python
CopyEdit
x = 10
if x > 5:
print("Big")
else:
print("Small")
❓ Questions:
1. What does a diamond represent in a flowchart?
2. Convert this flowchart to code:
○ Start → Input number → If even → Print "Even" → Else → Print "Odd"
🧠 2. Decomposition & Iterative Development
🔹 Definitions:
● Decomposition: Splitting problems into smaller tasks.
● Iterative Development: Repeating design, build, and test cycles.
⚙️ How it Works:
1. Break down big problems into parts.
2. Work on each part.
3. Test and refine continuously.
🖥️ Example:
Building a calculator:
● Step 1: Get inputs
● Step 2: Add/subtract/multiply
● Step 3: Output result
❓ Questions:
1. Name 2 benefits of decomposition.
2. Why do programmers use iterative development?
🔍 3. Binary Search
🔹 Definition:
A method to find a value in a sorted list by repeatedly halving the search area.
🧪 How It Works:
1. Check the middle.
2. If match → return.
3. If smaller → search left.
4. If larger → search right.
🖥️ Example:
List: [3, 6, 9, 12, 15]
Target: 12
Middle = 9 → 12 > 9 → move right → found 12.
❓ Questions:
1. Why must the list be sorted?
2. Compare binary and linear search.
🔁 4. Count-Controlled Loop
🔹 Definition:
A loop that repeats a fixed number of times.
🔧 Common Format:
python
CopyEdit
for i in range(5):
print("Hello")
🧪 Trace Table Example:
python
CopyEdit
x = 0
for i in range(3):
x += i
i x
0 0
1 1
2 3
❓ Questions:
1. What is the output of for i in range(4): print(i)?
2. What’s the final value of x above?
🔤 5. Data Types
🔹 Key Types:
● int – whole numbers (e.g. 5)
● float – decimals (e.g. 3.14)
● str – text (e.g. "hello")
● bool – true/false
🖥️ Example:
python
CopyEdit
name = "Max"
age = 16
height = 1.75
enrolled = True
❓ Questions:
1. What type is "123"?
2. Which type stores True/False?
⚠️ 6. Errors in Programming
🔹 Types:
● Syntax Error: Code violates Python grammar
● Logic Error: Runs but gives wrong results
● Runtime Error: Fails during execution
🧪 Debugging:
● Use print() to trace.
● Read error messages carefully.
● Test parts of your code in chunks.
🖥️ Example:
python
CopyEdit
x = int(input("Enter a number: "))
print(10 / x) # Crashes if x = 0
❓ Questions:
1. What kind of error happens if print("hi)?
2. How do you debug a runtime error?
📋 7. Writing a Test Plan
🔹 Definition:
A document showing how a program is tested, including inputs, expected results, and
outcomes.
🧪 Example Table:
Tes Description Input Expecte Actual Pass
t d ?
1 Valid number 5 25 25 ✅
2 Zero test 0 Error Error ✅
❓ Questions:
1. Why is a test plan important?
2. What sections are in a test table?
📘 Computing – Unit 9.6 Detailed Revision
Notes
1. Writing Python Code from a Flowchart
🧠 What is a Flowchart?
● A flowchart visually represents a process or algorithm using different shapes and
arrows.
● Each shape has a specific meaning:
○ Oval: Start/End of the program.
○ Rectangle: Instruction/Process (e.g., x = 5)
○ Diamond: Decision/Condition (e.g., if x > 10)
○ Arrows: Show the flow from one step to another.
💡 Example Flowchart:
css
Sao chépChỉnh sửa
[Start] → [x = 10] → [x > 5?] → Yes: print("Big") | No: print("Small")
🐍 Python Code Equivalent:
python
Sao chépChỉnh sửa
x = 10
if x > 5:
print("Big")
else:
print("Small")
🔁 Practice Tip:
When given a flowchart, identify:
1. Input/Start
2. Sequence of processes
3. Decision branches
4. Output
2. Decomposition & Iterative Development
🧩 Decomposition
● Breaking down a big problem into smaller, manageable parts (modules or functions).
● Makes code easier to write, test, and debug.
🔁 Iterative Development
● Building a system step-by-step.
● Each version is improved by:
1. Testing
2. Fixing errors
3. Enhancing features
🧮 Example: Calculator App
● Decomposition:
○ Input function
○ Calculation function
○ Output display
● Iteration: Test each part → improve if it fails → test again.
3. Binary Search
🔍 What is Binary Search?
● A fast algorithm to search for an item in a sorted list.
● Time Complexity: O(log n)
🔁 How It Works:
1. Find the middle of the list.
2. If it's the target → found.
3. If the target is smaller → search the left half.
4. If larger → search the right half.
📦 Example:
python
Sao chépChỉnh sửa
list = [2, 4, 6, 8, 10]
target = 8
● Step 1: Middle = 6 → 8 > 6 → go right.
● Step 2: Middle = 8 → FOUND!
⚠️ Important:
● List must be sorted before using binary search.
4. Count-Controlled Loops & Trace Tables
🔁 Count-Controlled Loop
● A loop that runs a fixed number of times.
● Syntax:
python
Sao chépChỉnh sửa
for i in range(3):
print(i)
● Output:
Sao chépChỉnh sửa
🧮 Trace Table
● A tool used to track how variables change during loop execution.
● Useful for debugging and understanding logic.
i
0
5. Data Types in Programming
🧠 Common Data Types:
Type Description Example
int Integer (whole number) 3, 100
float Decimal number 3.14,
1.5
str String/Text "hello
"
bool Boolean (True/False) True
✅ Example:
python
Sao chépChỉnh sửa
name = "Alice" # str
age = 17 # int
gpa = 3.75 # float
active = True # bool
⚠️ Why Important?
● Using correct types prevents bugs and improves program efficiency.
6. Types of Programming Errors
Type Description Example
Syntax Error Breaking language rules if x = 5 → should be ==
Logic Error Code runs but gives wrong if x > y: return x*y instead
result of x+y
Runtime Error Code crashes when it runs print(5 / 0) → Division by 0
🧰 Debugging Techniques:
● Use print() to check variable values.
● Read error messages carefully.
● Create and run multiple test cases.
7. Writing a Test Plan
📝 What is a Test Plan?
● A table used to ensure that a program behaves as expected with different inputs.
📊 Structure:
Test Description Input Expecte Actual Pass/Fai
# d l
1 Add 5 and 3 5+3 8 8 Pass
2 Divide by zero 10 / 0 Error Crash Fail
💭 Why Test Invalid Inputs?
● To ensure the program can handle errors without crashing.
8. Trace Tables and Iteration
● Trace tables help track values across iterations, especially in loops.
● They’re vital for spotting logic errors.
🧪 Example:
Problem: If x >= y, add them. Else, multiply.
python
Sao chépChỉnh sửa
x = 4
y = 3
if x > y:
result = x * y # ❌ Should be x + y
● Logic Error: Condition is true, but it multiplies instead of adding.
9. Online User Data & Big Data
🌐 How Data is Collected:
● Web tracking: pages visited, forms filled.
● Shopping behaviour: products viewed/purchased.
● Social Media: posts liked, location, keywords.
💸 Why is it Valuable?
● Helps companies target ads, understand customer interests, and improve sales.
💾 Big Data: 5 V’s
V Meaning
Volume Massive amounts of data
Velocity Speed of data generation
Variety Different types: video, text, numbers
Veracity Data accuracy and reliability
Value Usefulness of data to make
decisions