Class 12 Computer Science Revision Notes
1. REVISION TOUR 1: Basics of Python
Python Fundamentals:
- Keywords: if, else, for, def, etc.
- Identifiers: Names used for variables, functions, etc.
- Operators: Arithmetic, Relational, Logical, Assignment
- Data Types: int, float, complex, str, list, tuple, set, dict, bool
Input/Output:
- input(): for user input
- print(): to display output
Conditional Statements:
if condition:
# statements
elif condition:
# statements
else:
# statements
Loops:
- For Loop: for i in range(5): print(i)
- While Loop: while condition: # statements
- Loop Control: break, continue, pass
2. REVISION TOUR 2: Python Data Structures
Strings:
- Immutable sequence of characters
- Slicing: s[1:4]
- Methods: lower(), upper(), find(), replace(), split(), join()
Lists:
- Mutable: lst = [1, 2, 3]; [Link](4); [Link](2)
Tuples:
- Immutable: t = (1, 2, 3)
Dictionaries:
- Key-value pairs: d = {'name': 'Haru', 'age': 17}; d['age'] = 18
3. WORKING WITH FUNCTIONS
Function Basics:
def greet():
print("Hello")
greet()
Function with Parameters:
def add(a, b):
return a + b
Types of Functions:
- Built-in: len(), max(), type()
- User-defined
- Recursive:
def factorial(n):
if n == 1:
return 1
else:
return n * factorial(n - 1)
Scope of Variables:
- Global: Declared outside all functions
- Local: Declared inside a function
Return Statement:
- Ends the function and sends back a value
Extra Tips:
- Practice writing simple programs.
- Revise short questions (MCQs or 1-mark).
- Go through previous year questions.
- Pay attention to Python syntax: spacing, colons, indentation.