Chapter NotesClass 12 Computer Science
💻

Class 12 Computer ScienceChapter Notes

4 chapters · Definitions, key points, formulas & exam tips

Ch 1

Python — Exception Handling and File Handling

Key Definitions

Exception: A runtime error that disrupts normal program flow. Can be handled using try-except.
File Object: A Python object that represents an open file. Created using the open() function.

Key Points to Remember

  • Exception hierarchy: BaseException → Exception → specific exceptions (ValueError, ZeroDivisionError, FileNotFoundError).
  • try block: code that may raise exception. except: handles it. else: runs if no exception. finally: always runs.
  • File modes: 'r' (read), 'w' (write — creates/overwrites), 'a' (append), 'r+' (read+write), 'rb'/'wb' (binary).
  • Reading methods: read() — entire file as string, readline() — one line, readlines() — list of lines.
  • Writing: write(string) — no newline added automatically. writelines(list) — no newlines added.
  • Always close files: f.close() or use 'with open() as f:' context manager (auto-closes).
  • seek(n): move file pointer to position n. tell(): return current pointer position.

Formulas & Equations

with open('file.txt', 'r') as f: data = f.read()
try: ... except ExceptionType as e: ... else: ... finally: ...

Exam Tips

💡

Output questions on file handling: trace what's written to the file step by step.

💡

Binary files use pickle module: pickle.dump(obj, file) and pickle.load(file).

💡

CSV files: use csv.reader() and csv.writer() from the csv module.

Ch 2

Pandas — Series and DataFrame

Key Definitions

Series: A one-dimensional labelled array in Pandas. Like a column of a spreadsheet.
DataFrame: A two-dimensional labelled data structure with rows and columns. Like a spreadsheet or SQL table.

Key Points to Remember

  • Create Series: pd.Series(data, index=[]). Create DataFrame: pd.DataFrame({'col': [values]}).
  • Importing CSV: df = pd.read_csv('file.csv'). Key params: sep, header, index_col, usecols.
  • Selection: df['col'] or df[['col1','col2']] for columns. df.loc[label] for row by label. df.iloc[n] for row by position.
  • Boolean filtering: df[df['marks'] > 80].
  • Missing values: df.isnull() to check, fillna(value) to fill, dropna() to remove rows with NaN.
  • Aggregation: df['col'].sum(), mean(), max(), min(), count().
  • Grouping: df.groupby('col').agg({'col2': 'sum'}).
  • Key info methods: df.head(n), df.tail(n), df.describe(), df.info(), df.shape, df.dtypes.

Exam Tips

💡

loc uses labels; iloc uses integer positions — very common exam distinction.

💡

df.shape returns (rows, columns) as a tuple.

💡

For MCQs on Pandas: pd.read_csv returns a DataFrame; pd.Series creates a Series.

Ch 3

Computer Networks

Key Definitions

Protocol: A set of rules that govern data communication between devices. Examples: HTTP, FTP, TCP/IP.
IP Address: A unique numerical label assigned to each device on a network. IPv4: 32-bit. IPv6: 128-bit.
DNS (Domain Name System): Translates domain names (like www.google.com) into IP addresses.

Key Points to Remember

  • OSI model layers (bottom to top): Physical → Data Link → Network → Transport → Session → Presentation → Application.
  • TCP/IP model (4 layers): Network Access → Internet → Transport → Application.
  • Physical layer: actual bits transmitted. Data Link: frames, MAC address. Network: routing, IP address. Transport: TCP (reliable) / UDP (fast).
  • Network devices: Hub (broadcasts to all ports, layer 1), Switch (uses MAC address, layer 2, smarter), Router (connects different networks, layer 3, uses IP).
  • Common protocols: HTTP (web), HTTPS (secure web), FTP (file transfer), SMTP (send email), POP3/IMAP (receive email), DNS (name resolution), DHCP (auto IP assignment).
  • Packet switching: data broken into packets, each routed independently. More efficient than circuit switching.
  • Network types by coverage: PAN (personal) < LAN (building) < MAN (city) < WAN (country/world).

Exam Tips

💡

OSI model question: name all 7 layers in order — bottom to top (Physical to Application).

💡

Hub vs Switch vs Router: Hub = dumb (broadcasts), Switch = smart (MAC-based), Router = connects networks.

💡

TCP = reliable, connection-oriented (used for web, email). UDP = fast, connectionless (used for video streaming, DNS).

Ch 4

Database Concepts and SQL

Key Definitions

Primary Key: A column (or combination) that uniquely identifies each row in a table. Cannot be NULL.
Foreign Key: A column in one table that refers to the primary key of another table. Establishes relationships.
DDL / DML: DDL (Data Definition Language): CREATE, ALTER, DROP. DML (Data Manipulation Language): INSERT, UPDATE, DELETE, SELECT.

Key Points to Remember

  • RDBMS stores data in tables (relations). Each row = record, each column = field/attribute.
  • Candidate key: any minimal set that can uniquely identify rows. Primary key is chosen from candidate keys.
  • SELECT syntax: SELECT col FROM table WHERE condition GROUP BY col HAVING condition ORDER BY col ASC/DESC.
  • Aggregate functions: COUNT(*) — total rows, SUM(col) — total, AVG(col) — average, MAX/MIN(col).
  • WHERE filters before aggregation; HAVING filters after GROUP BY.
  • JOIN: INNER JOIN returns matching rows from both tables. LEFT JOIN returns all rows from left + matching from right.
  • NULL handling: IS NULL / IS NOT NULL (not = NULL or != NULL).
  • ALTER TABLE: ADD COLUMN, MODIFY COLUMN, DROP COLUMN. DROP TABLE: deletes entire table.

Formulas & Equations

SELECT col1, col2 FROM table WHERE condition ORDER BY col ASC;
SELECT dept, COUNT(*) FROM emp GROUP BY dept HAVING COUNT(*) > 5;
SELECT a.col, b.col FROM a INNER JOIN b ON a.id = b.id;

Exam Tips

💡

WHERE vs HAVING: WHERE filters rows (before grouping), HAVING filters groups (after GROUP BY).

💡

For JOIN questions: write the ON condition carefully — match primary key to foreign key.

💡

DISTINCT keyword: SELECT DISTINCT col — removes duplicate values from output.

CBSE Class 10 · Phase 2 Board Exam · May 2026

Appearing for the May Phase 2 Board Exam? Practice with AI-ranked questions.

Built for the May 2026 Phase 2 Board Exam — board paper analysis + unlimited practice for Maths, Science, English & SST.

Improvement · May 2026

Mathematics

299
599
Access to all CBSE Class 10 Maths chapters
Know which questions are most likely to come in your exam
Study by Chapter or by Section (A–E)
Step-by-step solutions for every question
AI-revealed high probability questions
Pattern recognition across past CBSE papers
Expected Paper for Phase 2 Board Exam (unlocks 3 weeks before)
Improvement · May 2026

Science

299
599
Access to all CBSE Class 10 Science chapters
Know which questions are most likely to come in your exam
Study by Chapter or by Section (A–E)
Step-by-step solutions for every question
AI-revealed high probability questions
Pattern recognition across past CBSE papers
Expected Paper for Phase 2 Board Exam (unlocks 3 weeks before)
★ Best Value · May 2026

Maths and Science

Maths · Science

+ SST & English Free
499
998
Both subjects — Maths & Science
Know which questions are most likely to come in your exam
Study by Chapter or by Section (A–E)
Step-by-step solutions for every question
AI-revealed high probability questions
Pattern recognition across past CBSE papers
Expected Paper for Phase 2 Board Exam (unlocks 3 weeks before)
Instant access
Valid till board exam
Secure payment — Razorpay
Phase 2 Board Exam · May 2026

CBSE Class 10 — Board Pattern