S0-SA3-0707
What is a Branch (Logic Primitive)?
Grade Level:
Pre-School – Class 2
All domains without exception
Definition
What is it?
A 'Branch' in logic is like choosing one path out of several options based on a condition. It allows a process to take different actions depending on whether something is true or false. Think of it as a decision point that directs the flow.
Simple Example
Quick Example
Imagine you're buying a train ticket. If you are a student, you get a discount. If not, you pay full price. This 'if-then' choice is a branch. The condition is 'Are you a student?', and based on the answer, the ticket price 'branches' differently.
Worked Example
Step-by-Step
Let's say you're building a simple program to decide if a student passes an exam.
1. Start with the student's marks: 45.
---
2. Define the passing condition: If marks are 40 or more, the student passes.
---
3. Check the condition: Is 45 (marks) >= 40 (passing marks)? Yes, it is true.
---
4. Based on the 'true' condition, the program 'branches' to the 'pass' action.
---
5. Display the result: "Student Passed!"
Answer: Student Passed!
Why It Matters
Branches are super important because they let systems make smart decisions automatically. Engineers use branches to control robots, app developers use them to show different content to users, and scientists use them in simulations. It's how computers think and react to different situations.
Common Mistakes
MISTAKE: Forgetting to define what happens if the condition is false. | CORRECTION: Always think about both outcomes: what happens if the condition is true, and what happens if it's false (the 'else' part).
MISTAKE: Making the condition unclear or too complex. | CORRECTION: Keep conditions simple and precise. For example, instead of 'If the weather is good', say 'If temperature > 25 degrees AND no rain'.
MISTAKE: Not considering all possible inputs that might affect the branch. | CORRECTION: Test your branch with different values, including boundary cases (like the exact passing mark) to ensure it works correctly for all scenarios.
Practice Questions
Try It Yourself
QUESTION: Your mobile data plan gives you 1GB extra data if your usage is less than 5GB this month. If your usage was 4.8GB, what happens? | ANSWER: You get 1GB extra data.
QUESTION: A traffic light system uses a branch. If a car is detected at the signal AND the light is red for more than 60 seconds, it turns green. If a car is detected and the light has been red for 45 seconds, what happens? | ANSWER: The light remains red because the 'red for more than 60 seconds' condition is not met.
QUESTION: A delivery app charges Rs. 50 delivery fee if the order is below Rs. 200. If the order is Rs. 200 or more, delivery is free. If a customer orders items worth Rs. 180, then adds a Rs. 30 item, what is the final delivery fee? Show the branch logic. | ANSWER: Initial order Rs. 180 (below Rs. 200) -> delivery fee Rs. 50. After adding Rs. 30, total order is Rs. 210 (Rs. 200 or more) -> delivery fee is free. Final delivery fee: Rs. 0.
MCQ
Quick Quiz
Which of these best describes a 'branch' in logic?
Repeating an action many times.
Choosing one path based on a condition.
Adding two numbers together.
Storing information in a list.
The Correct Answer Is:
B
A branch is fundamentally about making a decision and taking a different path based on whether a condition is true or false. Options A, C, and D describe other logical operations, not branching.
Real World Connection
In the Real World
When you use a UPI app like PhonePe or Google Pay, the app uses branches constantly. For example, 'IF your bank balance is sufficient AND the OTP is correct, THEN complete the payment, ELSE show an error message'. This ensures your transactions are handled correctly based on various checks.
Key Vocabulary
Key Terms
CONDITION: A statement that can be true or false. | TRUE: The outcome when a condition is met. | FALSE: The outcome when a condition is not met. | PATH: The sequence of actions taken after a decision.
What's Next
What to Learn Next
Now that you understand branching, you're ready to explore 'Loops'. Loops help you repeat actions many times, and often use branches inside them to decide when to stop. Keep learning, you're building a strong foundation!


