Python Revision Notes
Python Revision Notes
🧠 Syntax:
x = 10
name = "Aditya"
price = 99.5
🧠 Syntax:
if score > 90:
print("Excellent")
elif score > 60:
print("Good")
else:
print("Needs Improvement")
🧠 Syntax:
for i in range(5):
print(i)
🧠 Syntax:
def greet(name):
return f"Hello, {name}"
🧠 Syntax:
s = "hello"
s.upper() # 'HELLO'
s.replace("e", "a") # 'hallo'
"world" in s # False
📌 Lists
▶️Concept: Ordered, mutable collection.
🧠 Syntax:
fruits = ["apple", "banana"]
fruits.append("mango")
📌 Dictionaries
▶️Concept: Key-value pairs.
🧠 Syntax:
student = {"name": "Aditya", "score": 90}
student["score"] = 95
🧠 Syntax:
with open("data.txt", "r") as f:
content = f.read()
🧠 Syntax:
import pandas as pd
df = pd.read_csv("file.csv")
🧠 Syntax:
df["maths"] > 80
📌 Filtering Rows
▶️Concept: Use conditions to filter data.
🧠 Syntax:
df[df["maths"] > 80]