Total Pageviews

Wednesday, September 9, 2026

decision table,

```html

🐍 Decision Table

Definition • Structure • Rules • Examples • Python Implementation

1. What is a Decision Table?

A Decision Table is a tabular method used to represent different conditions and the actions that should be performed for each possible combination of conditions.

It is especially useful when a problem contains multiple conditions and multiple possible actions.

Simple Idea:
Conditions → Rules → Actions

2. Main Components of a Decision Table

1

Conditions

Conditions are the questions or situations that must be evaluated.

Example: Age ≥ 18?
2

Condition Entries

These indicate whether a condition is True, False, Yes, or No.

3

Actions

Actions are the operations performed when conditions are satisfied.

4

Rules

Each column generally represents one possible combination of conditions and its corresponding action.

3. General Structure of a Decision Table

Conditions
Condition 1 Y Y N
Condition 2 Y N Y
Actions
Action 1
Action 2

Here Y = Yes/True and N = No/False.

4. Example – Student Pass or Fail

Problem

A student passes if the marks are greater than or equal to 40. Otherwise, the student fails.

Decision Table

Condition / Action Rule 1 Rule 2
Marks ≥ 40? Yes No
Display "PASS"
Display "FAIL"

Python Program

marks = int(input("Enter marks: "))

if marks >= 40:
    print("PASS")
else:
    print("FAIL")

Output

Enter marks: 65 PASS

5. Example – Login System

Consider a login system with two conditions:

  • Username is correct.
  • Password is correct.

Decision Table

Condition / Action Rule 1 Rule 2 Rule 3 Rule 4
Username Correct? Yes Yes No No
Password Correct? Yes No Yes No
Login Successful
Login Failed

Python Implementation

username = input("Username: ")
password = input("Password: ")

if username == "admin" and password == "1234":
    print("Login Successful")
else:
    print("Login Failed")

Output

Username: admin Password: 1234 Login Successful

6. Example – Discount Calculation

Suppose a shop provides a discount based on purchase amount.

Condition / Action Rule 1 Rule 2 Rule 3
Amount ≥ 5000? Yes No No
Amount ≥ 2000? Yes No
20% Discount
10% Discount
No Discount

Python Program

amount = float(input("Enter purchase amount: "))

if amount >= 5000:
    discount = amount * 0.20
elif amount >= 2000:
    discount = amount * 0.10
else:
    discount = 0

final_amount = amount - discount

print("Discount =", discount)
print("Final Amount =", final_amount)

7. Advantages of Decision Tables

✅ Advantages

  • Easy to understand.
  • Clearly represents multiple conditions.
  • Helps identify missing combinations.
  • Reduces logical errors.
  • Useful for complex decision-making problems.
  • Helps programmers design conditional statements.
  • Useful for testing and test-case generation.
  • Provides clear documentation.
  • Easy to compare different rules.

❌ Disadvantages

  • Large numbers of conditions can create large tables.
  • Tables can become difficult to read.
  • Creating all possible combinations may be time-consuming.
  • Not ideal for simple sequential problems.
  • Complex actions may require additional explanation.
  • Frequent changes may require table modification.

8. Decision Table vs Flowchart

Decision Table Flowchart
Uses rows and columns. Uses graphical symbols.
Best for multiple conditions and combinations. Best for showing program flow.
Clearly shows different rules. Clearly shows sequence of operations.
Compact for complex decisions. Can become large for complex decisions.
Useful for generating test cases. Useful for understanding program execution.

9. Steps to Create a Decision Table

  1. Identify all important conditions.
  2. Identify all possible actions.
  3. List the possible values of each condition.
  4. Generate possible combinations of conditions.
  5. Create a separate rule for each combination.
  6. Determine the appropriate action for every rule.
  7. Remove impossible or unnecessary rules.
  8. Verify the completed decision table.

10. Important Points for Examination

  • A decision table represents decision logic in tabular form.
  • Conditions describe situations that must be evaluated.
  • Actions describe what should happen.
  • Each rule represents a combination of conditions.
  • Decision tables are useful when multiple conditions exist.
  • They can help identify missing or contradictory rules.
  • They are useful for designing and testing programs.
  • Decision tables can be converted into Python if-elif-else logic.

11. Quick Summary

Decision Table = A tabular representation of conditions, rules, and actions.

Basic Structure:
Conditions → Condition Values → Rules → Actions

Common Python Statements Used:
if → First condition
elif → Additional condition
else → Default action

Decision tables are particularly useful for complex decision-making and test-case design.
```

No comments:

Post a Comment