ClearStepsCLEARSTEPS AI
Chapter NotesClass 12 Computer Science
💻

Class 12 Computer ScienceChapter Notes

4 chapters · Definitions, key points, formulas & exam tips · Updated 2025-26

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.

Frequently Asked Questions

Are these notes based on 2025-26 CBSE syllabus for Class 12 Computer Science?

Yes. All chapter notes here are based on the latest 2025-26 CBSE syllabus for Class 12 Computer Science. Deleted topics are clearly marked so you focus only on what will be tested in your board exam.

How to study Class 12 Computer Science notes effectively for board exams?

Read each chapter's notes once to build understanding. Then close the notes and try to recall every key point, definition, and formula from memory. Anything you miss is your weak area — revisit only those points. This active recall method takes less time and retains far more than re-reading.

What is the difference between NCERT notes and chapter summaries?

Chapter notes contain detailed definitions, key terms, formulas, and concept breakdowns — they're for learning and understanding. Chapter summaries are shorter paragraph-style overviews — they're for quick revision. Use notes when you're studying a chapter for the first time; use summaries the night before the exam.

Do I need to memorise formulas for Class 12 Computer Science CBSE board exam?

Yes. Formulas listed in these notes must be memorised precisely — CBSE doesn't give formula sheets during exams. Write each formula 5–10 times, then recall it without looking. In the exam, write the formula first, then substitute values — this helps you earn partial marks even if the final answer has a calculation error.