0% found this document useful (0 votes)
76 views5 pages

Python Theory Notes for Class 11 CBSE

The document provides comprehensive Python theory notes for Class 11 (CBSE 2025 syllabus), covering topics such as Python basics, tokens, variables, data types, operators, control structures, strings, lists, tuples, dictionaries, functions, modules, errors, exceptions, and file handling. Each section includes definitions, examples, and explanations of key concepts. The notes are designed to be concise, clear, and exam-oriented.

Uploaded by

lodhihimanshi836
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views5 pages

Python Theory Notes for Class 11 CBSE

The document provides comprehensive Python theory notes for Class 11 (CBSE 2025 syllabus), covering topics such as Python basics, tokens, variables, data types, operators, control structures, strings, lists, tuples, dictionaries, functions, modules, errors, exceptions, and file handling. Each section includes definitions, examples, and explanations of key concepts. The notes are designed to be concise, clear, and exam-oriented.

Uploaded by

lodhihimanshi836
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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]()

You might also like