Class 12 Computer Science - Chapter 1: Python Revision Tour
1. Python Basics
- Python is a high-level, interpreted, object-oriented language.
- It uses indentation instead of braces.
2. Python Tokens
a) Keywords: Reserved words like if, else, def, etc.
b) Identifiers: Names for variables/functions.
c) Literals: Constants like 10, 3.14, "hello", True.
d) Operators: +, -, *, /, //, %, ==, !=, and, or, etc.
e) Punctuators: Symbols like (), {}, :, .
3. Data Types
- int, float, bool, str, list, tuple, dict, set.
4. Type Conversion
- Implicit: auto conversion by Python.
- Explicit: using int(), float(), str(), etc.
5. Input/Output
- input(): takes user input (string).
- print(): prints output.
6. Conditional Statements
- if, elif, else blocks.
7. Loops
- for loop: for i in range(5)
- while loop: while condition
8. Loop Control
- break: exits loop.
- continue: skips iteration.
- pass: placeholder.
9. Functions
- def function_name(): defines a function.
- return: returns a value.
- Built-in: len(), max(), range(), etc.
10. Modules
- import math
- from math import sqrt
Use modules for reusable code.