🔰 1. Python Basics
Your PDF starts by explaining why Python is so popular today.
✔ We live in a world full of data
Phones, laptops, smart TVs, watches generate huge amounts of data.
✔ Python handles this data efficiently
It has powerful libraries for:
- Data handling
- Data modelling
- Data visualization
- AI & Machine Learning
✔ Creator of Python
- Guido van Rossum
- First version: Python 0.9.0 (1991)
- Python 3.x is the most widely used today
🔰 2. Uses of Python (Page 241)
Python is used for:
- Web applications
- Standalone applications
- Scientific & statistical programs
- Graphical user interfaces
- AI & Machine Learning
Simple Definition
Python is a powerful, simple-to-learn programming language used everywhere—from websites to AI machines.
🔰 3. Features of Python (Pages 241–243)
Your PDF lists several important features:
⭐ 1. Easy to Learn (Syntax like English)
Example (from PDF):
age = 33
if age < 100:
print("Wow! I am alive!")
Simple, readable, clean.
⭐ 2. Open Source & Free
You can download free from python.org
You can modify and redistribute Python freely.
⭐ 3. High Level Language
You don’t need to worry about:
- Memory
- Devices
- Hardware
Python handles it automatically.
⭐ 4. Huge Standard Library
Contains modules for:
- Math
- GUI
- OS interactions
- Networking
- Scientific computing
⭐ 5. Portable
Runs on:
- Windows
- Mac
- Linux
- Mobile devices
- Web servers
⭐ 6. Both Compiler & Interpreter based
The PDF explains this clearly:
Source code → Bytecode (Compiler)
Bytecode → Machine code (Interpreter/PVM)
Compiler → catches syntax errors
Interpreter → stops program when runtime error occurs
⭐ 7. Indentation Makes Python Readable
Example in PDF (Page 242):
The block after if must be properly indented.
⭐ 8. Dynamic Typing
No need to declare type of variables.
x = 10
x = "Hello"
⭐ 9. Automatic Garbage Collection
Python automatically frees unused memory.
⭐ 10. Extensible Language
Can integrate with:
- C
- C++
🔰 4. Installing Python (Page 243)
Download: www.python.org/downloads
Install → Click Install Now
Then open from Start menu.
🔰 5. Python Execution Process (Compiler + Interpreter)
Your PDF explains Python’s working beautifully:
✔ Step 1
You write source code → program.py
✔ Step 2
Python compiler converts source code → bytecode (.pyc)
✔ Step 3
Python Interpreter (PVM) executes bytecode line-by-line.
🔰 6. Python IDLE (Page 244)
IDLE = Integrated Development and Learning Environment.
Contains:
- Editor
- Shell
- Debugger
Two modes:
⭐ Interactive Mode
- Type one command
- Get output immediately
- Prompt: >>>
Example:
>>> (1 + 7) * 2
16
⭐ Script Mode
- Write program
- Save file (.py)
- Run using F5
🔰 7. Working with Numbers (Page 245)
The PDF gives a table of arithmetic examples.
Examples:
| Command | Description |
|---|---|
2+2 | Simple addition |
43 - 7*9 | Mixed arithmetic |
(23+2*5)/5 | Division |
15/2 | 7.5 (float result) |
17//3 | Floor division |
5%2 | Remainder |
5**2 | Exponentiation (power) |
🔰 8. Strings in Python (Page 245–246)
Strings = Characters inside quotes.
Examples:
"Delhi"
"12345"
'Python is cool.'
⭐ Single quotes inside single quotes causes error
PDF example:
'Python isn't good' ❌ ERROR
"Python isn't good" ✔ Correct
🔰 9. Indexing in Strings (Page 246)
Index starts from 0.
P S E U D O C O D E
0 1 2 3 4 5 6 7 8 9
Negative index starts from end:
E = -1
D = -2
O = -3
Accessing elements:
str[0] = P
str[-1] = E
🔰 10. Script Mode (Page 247)
To create a program:
- File > New File
- Write code
- Save as
.py - Run → Run Module / Press F5
Errors appear in the Shell.
🔰 11. Comments in Python (Page 247)
Two types:
✔ Single-line comment
# This is a comment
✔ Multi-line comment
'''
comment lines
'''
OR
"""
comment lines
"""
🔰 12. Variables (Page 248)
Variable = Memory container for values.
Example:
name = "Arjun"
age = 16
price = 78.5
⭐ Naming Rules (Identifiers)
- Start with letter or underscore
- No special symbols
- No spaces
- Cannot use keywords
Valid:DOB, date_of_birth, ctr1
Invalid:12name, my-name, a@b
🔰 13. Data Types (Pages 248–250)
⭐ String
Inside quotes: "123", "Hello"
⭐ Integer (int)
Whole numbers
Memory: 4 bytes
⭐ Long
Very large integers (Only in old Python 2.x)
Example:149L
⭐ Float
With decimals: 3.14, 5.78
Scientific notation:x = 7.8e3
⭐ Boolean
True / False
Internally stored as 1 / 0.
🔰 14. Arithmetic in Python (Page 249–250)
Operands = values
Operators = + – * / // % **
Unary operator
-5 converts positive to negative.
🔰 15. Type Conversion (Page 251)
⭐ Implicit Conversion
Python converts automatically
a = 2 * 3.5 # becomes float
⭐ Explicit Conversion
Using functions:
int("3")
float(5)
str(62)
🔰 16. Input and Output (Page 250–251)
input() → always returns stringprint() → shows output
Example:
n = input("What is your name?")
print("Welcome", n)
🔰 17. Dual Role of + Operator (Page 251)
✔ Addition (numbers)
5 + 7 = 12
✔ Concatenation (strings)
"5" + "7" = "57"
🔰 18. Decision Making in Python (Pages 256–258)
⭐ if Statement
if number % 2 == 0:
print("Even")
⭐ if–else Statement
if marks >= 33:
print("Pass")
else:
print("Fail")
🔰 19. Loops in Python (Pages 257–260)
⭐ While Loop
Runs until condition becomes false.
i = 1
while i <= 10:
print(i)
i += 1
⭐ For Loop
Used for iterating through a list or range.
for i in range(1, 11):
print(i)
⭐ break
Stops the loop.
⭐ continue
Skips to next iteration.
🔰 20. Python Lists (Data Structures) (Pages 262–271)
Very detailed in PDF.
⭐ List Creation
cities = []
nums = [10, 20, 30]
mixed = [23, 'apple', 53.4]
⭐ List Indexing
mylist[0] → first item
mylist[-1] → last item
⭐ Slicing
mylist[2:6]
mylist[-5:-2]
⭐ Modify items
mylist[4] = "BIKE"
⭐ Add items
mylist.append("A")
mylist.extend([1,2,3])
mylist.insert(1, "New")
⭐ Remove items
mylist.remove("apple")
mylist.pop() # last item
⭐ Sort & Reverse
mylist.sort()
mylist.reverse()
⭐ Count items
mylist.count("apple")
⭐ Copy list
new = mylist.copy()
⭐ Nested List
traincar = [['Raj',1], ['vacant',2]]
traincar[0][0] # Raj