PYTHON PROGRAMMING — COMPLETE CLASS
NOTES
1. Introduction to Python
Python is a high-level, interpreted programming language. It is popular because:
- Easy syntax
- Huge community support
- Used in AI, Machine Learning, Web Development, Data Science, Automation, IoT, etc.
Python was created by Guido Van Rossum in 1991.
2. Python Installation & IDE Setup
Popular IDEs / Editors for Python:
- PyCharm
- VS Code
- Jupyter Notebook (Data Science)
- Spyder
- Google Colab
3. Python Variables
Variables store data in memory.
Example:
x = 10
name = "Hamza"
price = 75.50
4. Data Types
Python has built-in data types:
- int
- float
- str
- bool
- list
- tuple
- dictionary
- set
5. Operators
Arithmetic Operators: +, -, *, /
Comparison Operators: >, <, ==
Logical Operators: and, or, not
6. Conditional Statements (if/else)
age = 18
if age >= 18:
print("Eligible")
else:
print("Not eligible")
7. Loops in Python
Two loops:
- for loop (used for fixed iterations)
- while loop (runs until a condition becomes false)
Example:
for i in range(5):
print(i)
8. Functions
Functions allow code reuse.
Example:
def add(a, b):
return a + b
9. Object-Oriented Programming
Concepts:
- Class
- Object
- Inheritance
- Polymorphism
- Encapsulation
Example:
class Car:
def __init__(self, brand):
[Link] = brand
10. File Handling
Python can read/write files:
file = open("[Link]", "r")
[Link]()
11. Error & Exception Handling
try:
x = 10 / 0
except ZeroDivisionError:
print("Cannot divide by zero!")
12. Python Libraries (Important)
Data Science Libraries:
- NumPy
- Pandas
- Matplotlib
- Seaborn
- Scikit-Learn
- TensorFlow / Keras
13. Mini Project (Student Record System)
students = []
while True:
name = input("Enter name: ")
[Link](name)
print(students)
Data Type Comparison Table
Type Mutable? Indexed? Example
List Yes Yes [1,2,3]
Tuple No Yes (1,2,3)
Set Yes No {1,2,3}
Dictionary Yes Key-based {'a':1}