Python Handwritten Notes
1. Basics of Python
- Python is an interpreted, high-level, general-purpose programming language.
- Comments: Use # for single-line comments
- Print: print("Hello World")
- Variables: No need to declare type
name = "Kashish"
age = 18
- Data Types: int, float, str, bool, NoneType
- Type checking: type(var)
- Input: input("Enter name: ")
2. Control Flow
- If-Else Statement:
if condition:
# code
elif another_condition:
# code
else:
# code
- Loops:
while condition:
# code
for i in range(5):
print(i)
- Loop Control: break, continue, pass
Python Handwritten Notes
3. Functions
- Function Syntax:
def function_name(parameters):
# code
return value
- Example:
def add(a, b):
return a + b
- Default Arguments, Keyword Arguments
- Scope: local vs global variables
4. Data Structures
- List: Ordered, Mutable
fruits = ["apple", "banana", "cherry"]
fruits.append("mango")
fruits[0] = "orange"
- Tuple: Ordered, Immutable
tup = (1, 2, 3)
- Dictionary: Key-Value pairs
info = {"name": "Kashish", "age": 18}
print(info["name"])
- Set: Unordered, No duplicates
s = {1, 2, 3, 2}
s.add(4)