Python Interview Notes (Simple Hinglish) - Basic to
Advanced
1. Python Basics
What is Python?
Python ek high-level, easy-to-read programming language hai.
Why popular? Simple syntax, automation, web development, data science, AI.
Example:
x = 10
print(x)
2. Data Types & Variables
int=10, float=10.5, str='Sonu', bool=True, list=[1,2].
Mutable: List, Dictionary, Set.
Immutable: String, Tuple.
Type Casting: int('10'), str(100).
3. Operators
Arithmetic: + - * / % // **
Comparison: == != > < >= <=
Logical: and, or, not
Example: 10 % 3 = 1
4. Control Flow
if, elif, else decision making ke liye.
for loop repeat karne ke liye.
while loop condition true hone tak chalta hai.
break = loop stop, continue = next iteration.
5. Strings
String text data hota hai.
Example: name='Sonu'
Indexing: name[0]
Slicing: name[0:3]
f-string: f'My name is {name}'
6. Lists
Ordered, mutable collection.
nums=[1,2,3]
append(), remove(), insert(), pop().
List Comprehension: [x*x for x in range(5)]
7. Tuples
Tuple immutable collection hai.
t=(1,2,3)
Data change nahi kar sakte.
8. Sets
Unique values store karta hai.
s={1,2,3}
Operations: union(), intersection(), difference().
9. Dictionaries
Key-Value pair store karta hai.
student={'name':'Sonu','age':25}
Access: student['name']
10. Functions
Reusable block of code.
def add(a,b):
return a+b
Lambda: lambda x:x*2
11. OOPs Concepts
Class blueprint hota hai, Object uska instance.
4 Pillars:
1. Encapsulation
2. Inheritance
3. Polymorphism
4. Abstraction
12. Exception Handling
Errors handle karne ke liye.
try:
x=10/0
except ZeroDivisionError:
print('Error')
13. Modules & Packages
Module = single .py file.
Package = modules ka folder.
Import Example:
import math
[Link](25)
14. File Handling
f=open('[Link]','r')
data=[Link]()
[Link]()
Modes: r,w,a.
15. Advanced Concepts
Decorator: function modify karta hai.
Generator: yield keyword use karta hai.
Iterator: next() support karta hai.
GIL: ek time par ek thread Python bytecode execute karta hai.