SYSTEMATIC PYTHON NOTES
1. DATA TYPES BASICS
- String: Text data inside quotes (“Hello”)
- List: Ordered, changeable collection [1,2,3]
- Tuple: Ordered, unchangeable collection (1,2,3)
- Dictionary: Key–value pairs {"name": "John"}
2. FOR LOOP VS WHILE LOOP
- For loop: Repeats for fixed range/sequence
- While loop: Repeats until condition becomes false
3. FILE HANDLING
- r = read
- w = write
- a = append
- x = create
- with open(...) auto-closes file
4. CSV AND TEXT FILES
- .txt → plain text
- .csv → comma separated values (used for tables/datasets)
5. FUNCTIONS
• Built■in functions → print(), len(), sum()
• User■defined functions → created using def
6. RECURSION
A function that calls itself
Example:
def fact(n):
if n==1: return 1
return n * fact(n-1)
7. CONCATENATION
Joining strings:
"Hello " + "World"
8. OOP CONCEPTS
A. Class → blueprint to create objects
B. Inheritance → child class gets properties of parent
C. Encapsulation → hiding data inside class
D. Abstraction → showing only essential details
Difference:
Encapsulation = hides data using methods/variables
Abstraction = hides complexity, shows only necessary parts
9. DIVISION OPERATORS
- / → normal division (gives decimal)
- // → floor division (whole number)
10. EXCEPTION HANDLING
try:
code
except:
handles error
else:
runs if no error
finally:
runs always
11. PASS STATEMENT
A null statement that does nothing (placeholder)
12. FUNCTION ARGUMENTS
- Positional arguments
- Keyword arguments
- Default arguments
- *args → many values
- **kwargs → many keyword values