←Back to Subject
Notes
Notes
Study material and explanations
Diagrams
Diagrams
Visualize concepts easily
Mnemonics
Mnemonics
Tricks to remember faster
One Night Prep
One Night Prep
Short and focused revision
Revision
Revision
Quick summary and key points
Important Questions
Important Questions
Practice most relevant questions
Diagrams

Diagrams

Visual representations for Unit 2

Classification of Control Statements in Python

Classification of Control Statements in Python
1. Conditional (Decision)
if, if-else, if-elif-else, Nested if
2. Looping (Iterative)
for loop, while loop
3. Jump (Transfer)
break, continue, pass
Explanation
  • Selection chooses which block to execute and loops repeat work.
  • Break and continue change how the current loop proceeds.
Detailed Notes →Quick Revision →

Execution Flow of if-elif-else

Execution Flow of if-elif-else
Check Condition 1 (if)
→ False →
Check Condition 2 (elif)
→ False →
Execute Default (else)
Explanation
  • Conditions are tested from the first if down through the elif branches.
  • Only the first true branch runs, or the else branch runs when none is true.
Detailed Notes →Quick Revision →

Positive & Negative Indexing in Python ("PYTHON")

Positive & Negative Indexing in Python ("PYTHON")
0
P
-6
1
Y
-5
2
T
-4
3
H
-3
4
O
-2
5
N
-1
Explanation
  • Count from zero on the left or from minus one on the right.
  • Both indexes above and below a letter refer to the same position in PYTHON.
Detailed Notes →Quick Revision →

Mathematical Set Operations (Let A = {1, 2, 3} and B = {3, 4, 5})

Mathematical Set Operations (Let A = {1, 2, 3} and B = {3, 4, 5})
1. Union (A | B)
All unique elements from both sets: {1, 2, 3, 4, 5}
2. Intersection (A & B)
Only common elements in both sets: {3}
3. Difference (A - B)
Elements in A but NOT in B: {1, 2}
4. Symmetric Diff (A ^ B)
Elements in A or B, excluding common ones: {1, 2, 4, 5}
Explanation
  • Union collects distinct members from either set and intersection keeps shared members.
  • Difference keeps members found only on the chosen side.
Detailed Notes →Quick Revision →

Types of Functions in Python

Types of Functions in Python
1. Built-in Functions
Pre-defined in Python: print(), len(), type(), input(), max()
2. User-Defined Functions
Created by the programmer using the def keyword
3. Lambda Functions
Single-line anonymous (nameless) functions using lambda
4. Recursive Functions
A function that calls itself (e.g., calculating factorial)
Explanation
  • A built-in function is supplied by Python and a user-defined function is written with def.
  • A lambda expression creates a function whose body is a single expression.
Detailed Notes →Quick Revision →

How map(), filter(), and reduce() Work on [1, 2, 3, 4]

How map(), filter(), and reduce() Work on [1, 2, 3, 4]
1. map(func, seq)
Transforms every item in the list.
[1, 2, 3, 4] → square → [1, 4, 9, 16]
2. filter(func, seq)
Selects only items where condition is True.
[1, 2, 3, 4] → even → [2, 4]
3. reduce(func, seq)
Combines all items into a single value.
[1, 2, 3, 4] → sum → 10
Explanation
  • Map transforms each input and filter keeps inputs that pass a test.
  • Reduce combines the sequence into one accumulated result.
Detailed Notes →Quick Revision →