Class 12 Computer Science – Chapter 1 Detailed Notes
Introduction
• Python is a high-level, general-purpose, interpreted, object-oriented programming
language.
• It is widely used for software development, web development, AI, ML, data science,
automation, etc.
• Python is open-source and platform-independent.
Python Basics
• Tokens in Python: Keywords, Identifiers, Literals, Operators, Punctuators.
• Data Types: int, float, complex, list, tuple, range, str, set, frozenset, dict, bool, None.
• Variables: Names given to store values in memory.
• Operators: Arithmetic, Relational, Logical, Assignment, Bitwise, Membership, Identity.
Input & Output
• Input: input() function takes input as a string.
• Output: print() function is used to display output.
• Formatting output using format() or f-strings.
Control Structures
• Decision Making: if, if-else, if-elif-else statements.
• Looping: for loop, while loop, nested loops.
• Loop control statements: break, continue, pass.
Functions
• Functions are reusable blocks of code.
• Types: Built-in functions and User-defined functions.
• Arguments: positional, keyword, default, variable length (*args, **kwargs).
Modules & Packages
• Module: A file containing Python code.
• Package: A collection of modules stored in a directory.
Error & Exception Handling
• Error types: Syntax errors and Runtime errors (Exceptions).
• Handled using try, except, else, finally blocks.
• raise and assert statements used to raise exceptions.
File Handling (Basics)
• open(filename, mode) function is used.
• Modes: r (read), w (write), a (append), rb (read binary), wb (write binary).
• Use read(), write(), close() methods.
Important Python Features
• Simple & easy to learn
• Object-Oriented
• Portable & platform independent
• Large library support
• Dynamic typing
• Interpreted language