🐍 FLOWCHART
Graphical Representation of Program Logic
1. What is a Flowchart?
A flowchart helps a programmer understand the logic of a problem before writing the actual Python program.
Problem → Algorithm → Flowchart → Program → Output
2. Purpose of a Flowchart
- To represent program logic visually.
- To make complex problems easier to understand.
- To plan a program before coding.
- To identify logical errors.
- To explain a program to others.
- To document the program.
- To help in debugging and testing.
3. Standard Flowchart Symbols
Terminator
Represents the beginning or termination of a program.
Process
Represents a calculation or processing operation.
Input / Output
Represents data input or output.
Decision
Represents a condition with different possible outcomes.
Flow Line
Shows the direction of program execution.
4. Basic Flowchart Structure
5. Example 1 – Addition of Two Numbers
Problem
Take two numbers as input and calculate their sum.
Algorithm
- Start.
- Input two numbers A and B.
- Calculate SUM = A + B.
- Display SUM.
- Stop.
Flowchart
Python Program
a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
sum = a + b
print("Sum =", sum)
Output
6. Example 2 – Even or Odd
Problem
Determine whether a given number is even or odd.
Flowchart
Python Program
n = int(input("Enter a number: "))
if n % 2 == 0:
print("Even Number")
else:
print("Odd Number")
Output
7. Example 3 – Loop Flowchart
Flowcharts can represent repetition or looping operations.
Problem
Display numbers from 1 to 5.
Flowchart
Python Program
for i in range(1, 6):
print(i)
Output
8. Advantages of Flowchart
✅ Advantages
- Easy to understand.
- Provides a visual representation of logic.
- Helps in program planning.
- Makes complex logic easier to understand.
- Helps identify logical errors.
- Useful for debugging.
- Improves communication among programmers.
- Useful for teaching programming.
- Provides program documentation.
- Language independent.
❌ Disadvantages
- Creating large flowcharts can be time-consuming.
- Complex programs may require very large diagrams.
- Modification can be difficult.
- Large flowcharts require more space.
- Flow lines may cross in complex diagrams.
- Not every programming detail is easy to represent.
- Maintenance of large flowcharts can be difficult.
- A major program change may require redrawing.
9. Rules for Drawing a Flowchart
- Use standard flowchart symbols.
- Begin with a START symbol.
- End with an END symbol.
- Use arrows to indicate the direction of flow.
- Normally draw the flow from top to bottom or left to right.
- Use the diamond symbol for decisions.
- Clearly label decision branches such as YES and NO.
- Avoid unnecessary crossing of flow lines.
- Keep the flowchart simple and readable.
- Use meaningful descriptions inside each symbol.
10. Algorithm vs Flowchart
| Algorithm | Flowchart |
|---|---|
| Written step-by-step procedure. | Graphical representation of the procedure. |
| Uses words and statements. | Uses symbols and arrows. |
| Usually easier to write. | Usually easier to visualize. |
| Good for describing detailed steps. | Good for showing program flow. |
| Can be modified relatively easily. | Modification may require redrawing. |
11. Important Points for Examination
- Flowchart is a graphical representation of an algorithm.
- Oval represents Start or End.
- Rectangle represents Process.
- Parallelogram represents Input or Output.
- Diamond represents Decision.
- Arrows indicate the direction of flow.
- Flowcharts are useful for program planning.
- Flowcharts help in understanding and debugging program logic.
- Flowcharts can represent sequence, selection and repetition.
12. Quick Summary
Important Symbols:
🟢 Oval → Start / End
▭ Rectangle → Process
▱ Parallelogram → Input / Output
◇ Diamond → Decision
→ Arrow → Direction of Flow
Program Development:
Problem → Algorithm → Flowchart → Python Program → Output
No comments:
Post a Comment