Here’s a complete Python Theory Notes (Class 11, CBSE - 2025 syllabus) — concise, clear,
and exam-oriented.
Python Theory Notes – Class 11 (CBSE)
1. Basics of Python
1.1 Introduction to Python
Python is a high-level, interpreted, and general-purpose programming language.
Created by Guido van Rossum in 1991.
Features:
o Easy to learn and use
o Open-source and free
o Interpreted language
o Portable and platform-independent
o Object-oriented and extensible
o Large library support
1.2 Python Character Set
Letters (A–Z, a–z)
Digits (0–9)
Special symbols (+, -, *, /, %, @, #, etc.)
Whitespace characters (space, tab, newline)
Other characters (like Unicode characters)
2. Tokens in Python
Smallest units in a Python program.
Types of Tokens:
1. Keywords – reserved words (e.g., if, else, for, while, break, True, False)
2. Identifiers – names for variables, functions, etc.
o Must start with a letter or underscore
o Case-sensitive
o Cannot be a keyword
3. Literals – constant values
o Numeric (e.g., 10, 3.14)
o String (e.g., "Hello")
o Boolean (True, False)
o Special (None)
4. Operators – symbols used for operations (e.g., +, -, *, /, ==, <, and, or)
5. Punctuators – characters like (), {}, [], ,, :, ;
3. Variables and Data Types
Variable
A name given to a memory location that stores data.
Example:
x = 10
name = "Riya"
Data Types
Type Example Description
int 5, -2 Integer numbers
float 3.14, -9.8 Decimal numbers
str "Hello" String of characters
bool True, False Boolean values
NoneType None Represents no value
4. Operators in Python
Type Operators Example
Arithmetic +, -, *, /, %, **, // a + b
Relational ==, !=, >, <, >=, <= a > b
Logical and, or, not a and b
Assignment =, +=, -=, *=, /= x += 5
Membership in, not in 'a' in "cat"
Identity is, is not a is b
5. Input and Output
Input:
name = input("Enter name: ")
age = int(input("Enter age: "))
Output:
print("Hello", name)
print(f"Your age is {age}")
6. Control Structures
6.1 Conditional Statements
if condition:
statement
elif condition:
statement
else:
statement
6.2 Looping Statements
For Loop:
for i in range(1, 6):
print(i)
While Loop:
i = 1
while i <= 5:
print(i)
i += 1
Loop Control Statements:
break – exit loop
continue – skip iteration
pass – null statement (does nothing)
7. Strings
String Operations
s = "Python"
print(len(s)) # Length
print(s[0]) # Indexing
print(s[1:4]) # Slicing
print([Link]()) # Convert to lowercase
print([Link]()) # Convert to uppercase
print([Link]("Py", "My")) # Replace
String Concatenation:
a = "Hello"
b = "World"
print(a + " " + b)
8. Lists
A list is an ordered, mutable collection of items.
fruits = ["apple", "banana", "cherry"]
Operations:
print(len(fruits))
[Link]("orange")
[Link]("banana")
print(fruits[1])
9. Tuples
Immutable ordered collection.
t = (10, 20, 30)
print(t[1])
10. Dictionaries
Key–value pairs.
student = {"name": "Riya", "age": 17, "class": 11}
print(student["name"])
11. Functions
Defining Functions
def greet(name):
print("Hello", name)
greet("Amit")
Return Statement
def add(a, b):
return a + b
12. Modules and Libraries
Importing Modules
import math
print([Link](16))
Common Modules:
math – mathematical functions
random – random number generation
datetime – date and time
statistics – statistical calculations
13. Errors and Exceptions
Common Errors
Syntax Error
Runtime Error
Logical Error
Exception Handling
try:
a = int(input("Enter number: "))
b = 10 / a
except ZeroDivisionError:
print("Cannot divide by zero")
finally:
print("Program ended")
14. File Handling (Basics)
Opening a File
f = open("[Link]", "r")
content = [Link]()
print(content)
[Link]()
Writing to File
f = open("[Link]", "w")
[Link]("Hello Python")
[Link]()