01. Python Revision Tour

Reviewing the fundamentals: Tokens, Flow of Control, and Mutable/Immutable types.

Python Tokens Overview

Token Type Examples
Keywords if, while, for, break
Identifiers myVar, _count, totalMarks
Literals 12, 3.14, "Hello", True
Operators +, -, *, //, **
Evaluator's Note 📝

Board Exam Secret:

1-mark questions frequently test Invalid Identifiers.

  • • Identifier cannot start with a digit.
  • • No spaces allowed.
  • • Special characters are not allowed except underscore (_).
  • • Keywords cannot be used as identifiers.

List Slicing in Practice

list_slicing.py

L = [10, 20, 30, 40, 50, 60]

print(L[1:5])    # Output: [20, 30, 40, 50]
print(L[::-1])   # Output: [60, 50, 40, 30, 20, 10]
print(L[2:])     # Output: [30, 40, 50, 60]
                        

Mutable vs Immutable Types

Mutable

  • • List
  • • Dictionary
  • • Set

Immutable

  • • int
  • • float
  • • string
  • • tuple

02. Functions (Def & Arguments)

Understanding Python Functions

A function is a reusable block of code that performs a specific task. They are the building blocks of modular programming, helping to break complex problems into smaller, manageable pieces (e.g., `calc_tax()`, `send_email()`).

Types of Functions

1. Built-in

Pre-defined in Python.
print(), len(), type()

2. Modules

Imported from libraries.
math.sqrt(), random.randint()

3. User-Defined

Created by programmers.
def my_func():

Core Components

  • def : Keyword to define
  • name : Identifier for function
  • parameters : Inputs received
  • arguments : Values passed
  • return : Output to caller
  • call : Invoking execution
Evaluator's Note 📝

Topic: Scope of Variables

Board exams frequently test if you know when a variable is Local or Global.

  • Local: Created inside function. Accessible ONLY inside.
  • Global: Created outside function. Accessible everywhere.
  • Trap: To modify a global variable inside a function, you MUST use the global keyword first.

Factorial Function Example

factorial.py

def factorial(n):
    result = 1
    # Loop from 1 to n
    for i in range(1, n + 1):
        result *= i
    return result  # Returns final value

num = 5
# Function Call
print("Factorial:", factorial(num)) 
# Output: Factorial: 120
                        

03. File Handling (Text, Binary, CSV)

Reading/Writing persistent data. Text files (`read()`, `readlines()`), Binary (`pickle`), and CSV modules are guaranteed 3-5 mark questions.

binary_search.py

import pickle

def search_record(roll_no):
    found = False
    try:
        with open('student.dat', 'rb') as f:
            while True:
                rec = pickle.load(f)
                if rec['roll'] == roll_no:
                    print("Found:", rec)
                    found = True
                    break
    except EOFError:
        pass
    
    if not found:
        print("Record not found.")
                        
Evaluator's Note 📝

Binary File Trap: Always use `try-except EOFError` block when reading binary files with `pickle.load()` inside a loop. Without it, your program will crash at the end of file.

04. Stacks (Data Structures)

Understanding Stack (LIFO Principle)

Stack is a linear data structure that follows the LIFO (Last In First Out) principle. Conceptualize it like a stack of plates: the last plate placed on top is the first one removed.

TOP
[ 30 ]
[ 20 ]
[ 10 ]
BOTTOM

Core Stack Operations

  • Push
    Add element to top (append)
  • Pop
    Remove element from top (pop)
  • Peek
    View top element (-1 index)
  • Underflow
    Popping from empty stack
Evaluator's Note 📝

Board Implementation:

In Python board exams, Stack is always implemented using a List.

  • Push: Use list.append(item)
  • Pop: Use list.pop()
  • Critical Rule: Always check for Underflow (empty list) before popping. Missing this check = lost marks.

Menu-Driven Stack Implementation

stack_menu.py

s = []

def push():
    item = int(input("Enter element: "))
    s.append(item)
    print("Stack after push:", s)

def pop_element():
    if len(s) == 0:
        print("Underflow - Stack is empty")
    else:
        print("Popped element:", s.pop())

def display():
    if len(s) == 0:
        print("Stack is empty")
    else:
        print("Stack elements:", s)

while True:
    print("\n1. Push\n2. Pop\n3. Display\n4. Exit")
    choice = int(input("Enter choice: "))

    if choice == 1:
        push()
    elif choice == 2:
        pop_element()
    elif choice == 3:
        display()
    elif choice == 4:
        break
    else:
        print("Invalid choice")
                        

05. SQL & Interface

Structured Query Language involving `SELECT`, `GROUP BY`, `HAVING`, and Python-SQL connectivity (`mysql.connector`).

sql_connect.py

import mysql.connector as sqlt
con = sqlt.connect(host='localhost', user='root', passwd='password', database='school')
cursor = con.cursor()

cursor.execute("SELECT * FROM Student WHERE Marks > 90")
data = cursor.fetchall()

for row in data:
    print(row)

con.close()
                        
Evaluator's Note 📝

Query Trap: `WHERE` clause filters rows *before* grouping. `HAVING` clause filters groups *after* grouping. Mixing them up results in 0 marks for that query.

06. Computer Networks

A. Network Types

Type Full Form Range Example
PAN Personal Area ~10 m Bluetooth
LAN Local Area Building Office Wi-Fi
MAN Metropolitan City Cable TV
WAN Wide Area Global Internet

"Memory Trick: PAN = Personal, LAN = Local, MAN = Metropolitan, WAN = World."

B. Key Topologies

STAR

All nodes connect to a central Hub/Switch.

  • Adv: Easy failure detection.
  • Disadv: More cable needed.
BUS

Single cable (backbone) connects all nodes.

  • Adv: Less cable required.
  • Disadv: Cable break stops all.
TREE

Hierarchical structure (Bus + Star).

  • Adv: Easy expansion.
  • Disadv: Complex config.

C. Protocols & Terms

TCP/IP: Standard Internet Protocol suite. HTTP/S: HyperText Transfer Protocol (Secure). FTP: File Transfer Protocol. DNS: Domain Name System (URL to IP).

IP Address vs MAC Address

Feature IP Address MAC Address
Type Logical (Software) Physical (Hardware)
Assigned ISP / Network Manufacturer
Changeable Yes No
🌟 Evaluator's Secret (4-5 Marks Booster)

"Board exam mein 4-5 marks ka ek 'Case Study' question hamesha aata hai jisme Layout design karna hota hai."

Golden Rules:

  • Server Placement: Always in the building with the Maximum Number of Computers.
  • Repeater: Install if wire distance > 70-100 meters.
  • Device: Switch is preferred over Hub for connecting computers in a block.

Mastering the 5-Mark Case Study

Problem Statement:

Buildings: A (25 PCs), B (40 PCs), C (15 PCs), D (20 PCs)
Distances: A-B (50m), A-C (120m), B-D (80m), C-D (60m)

Evaluator's Solution:

  • Server Location: Building B (Because it has max 40 computers). - 1 Mark
  • Cable Layout: Star Topology connecting Server (B) to other nodes (A, D, C). Check distances. - 1 Mark
  • Repeater: Required between A and C (Distance is 120m, which > 100m). - 1 Mark
  • Device: Switch (for connecting computers within each building). - 1 Mark