1. Algorithm Design
Before writing code, algorithms are designed using two techniques:
- Flowcharts: Graphical logic mapping using standard symbols: Terminal (Oval), Input/Output (Parallelogram), Process (Rectangle), Decision (Diamond), and Flowlines (Arrows).
- Pseudo-code: A human-readable text-based description of logic, structured using keywords like
IF-THEN-ELSEorWHILE.
2. Python Control Structures
Python scripts execute code through three structures:
- Sequence: Executing lines of code one after another.
- Selection (if-elif-else):
score = int(input("Enter marks: ")) if score >= 75: grade = "A" elif score >= 65: grade = "B" else: grade = "C" print("Grade:", grade) - Iteration (Looping):
# Printing even numbers from 2 to 10 for i in range(2, 11, 2): print(i)
3. Python Data Structures
- List: Ordered, mutable collection. Written with square brackets.
numbers = [10, 20, 30] - Tuple: Ordered, immutable collection. Written with parentheses.
point = (4, 5) - Dictionary: Key-value store. Unordered and mutable.
student = {"name": "Ranindu", "index": 4810}