Python Notes (Basic to Intermediate)
1. Introduction to Python
Python ek high-level, easy-to-learn programming language hai. Iska use web development, data
science, automation, AI, aur software development me hota hai.
2. Variables
Variables data store karne ke liye use hote hain.
Example:
x = 10
name = 'Anish'
3. Data Types
Common data types:
- int (integer)
- float (decimal)
- str (string)
- bool (True/False)
Example:
a=5
b = 3.14
c = 'Hello'
4. Input and Output
User se input lene ke liye input() function use hota hai.
Example:
name = input('Enter your name: ')
print(name)
5. Operators
Arithmetic: +, -, *, /, %
Comparison: ==, !=, >, <
Logical: and, or, not
6. Conditional Statements
Decision lene ke liye if-else use hota hai.
Example:
x = 10
if x > 5:
print('Greater')
else:
print('Smaller')
7. Loops
for loop aur while loop repetition ke liye use hote hain.
Example (for):
for i in range(5):
print(i)
Example (while):
i=0
while i < 5:
print(i)
i += 1
8. Functions
Function code ko reusable banata hai.
Example:
def add(a, b):
return a + b
9. Lists
List ek collection hoti hai.
Example:
nums = [1, 2, 3, 4]
print(nums[0])
10. Tuples
Tuple list jaisa hota hai lekin immutable (change nahi hota).
Example:
t = (1, 2, 3)
11. Dictionaries
Key-value pairs store karne ke liye.
Example:
student = {'name': 'Anish', 'age': 20}
12. File Handling
File read/write karne ke liye open() function use hota hai.
Example:
f = open('[Link]', 'w')
[Link]('Hello')
[Link]()
13. OOP Basics
Class aur object concept.
Example:
class Student:
def __init__(self, name):
[Link] = name