Complete Python Handbook
This handbook is an original educational guide designed for beginners to intermediate learners. It covers Python
programming concepts with simple explanations, examples, and exercises.
1. Introduction to Python
Python is a popular programming language used in:
- Web Development
- Artificial Intelligence
- Data Science
- Automation
- Game Development
Example:
print("Hello World")
2. Variables and Data Types
Variables store data.
Example:
name = "Rahul"
age = 14
height = 5.4
Data Types:
- String
- Integer
- Float
- Boolean
3. Input and Output
Input Example:
name = input("Enter your name: ")
Output Example:
print("Hello", name)
4. Operators
Arithmetic Operators:
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus
Example:
print(10 + 5)
5. Conditions
Conditions help computers make decisions.
Example:
age = 18
if age >= 18:
print("Adult")
else:
print("Minor")
6. Loops
For Loop:
for i in range(5):
print(i)
While Loop:
count = 1
while count <= 5:
print(count)
count += 1
7. Functions
Functions help reuse code.
Example:
def greet():
print("Hello")
greet()
8. Lists
Lists store multiple values.
Example:
fruits = ["Apple", "Mango", "Banana"]
print(fruits[0])
9. Tuples
Tuples are ordered collections.
Example:
numbers = (1, 2, 3)
print(numbers)
10. Sets
Sets store unique values.
Example:
colors = {"red", "blue", "green"}
print(colors)
11. Dictionaries
Dictionaries store key-value pairs.
Example:
student = {
"name": "Rahul",
"age": 14
}
print(student["name"])
12. String Methods
Example:
text = "python"
print([Link]())
print([Link]())
print(len(text))
13. File Handling
Writing File:
file = open("[Link]", "w")
[Link]("Hello")
Reading File:
file = open("[Link]", "r")
print([Link]())
14. Exception Handling
Example:
try:
print(10 / 0)
except:
print("Error occurred")
15. Modules
Example:
import math
print([Link](25))
16. Object Oriented Programming
Class Example:
class Student:
def __init__(self, name):
[Link] = name
s1 = Student("Rahul")
print([Link])
17. Python Projects
Project Ideas:
- Calculator
- Quiz Game
- Student Management System
- Number Guessing Game
- ATM Simulator
- To-Do List
18. Practice Questions
1. Write a program to add two numbers.
2. Check even or odd.
3. Create multiplication table.
4. Find largest number.
5. Make simple calculator.
Topic Skill Learned
Variables Store data
Conditions Decision making
Loops Repeating tasks
Functions Reusable code
Lists Store collections
OOP Create objects/classes