Post content
Quick Python Cheat Sheet for Beginners 🐍✍️ Python is widely used for data analysis, automation, and AI—perfect for beginners starting their coding journey. Aggregation Functions 📊 • sum(list) → Adds all values 👉 sum([1,2,3]) = 6 • len(list) → Counts total elements 👉 len([1,2,3]) = 3 • max(list) → Highest value 👉 max([4,7,2]) = 7 • min(list) → Lowest value 👉 min([4,7,2]) = 2 • sum(list)/len(list) → Average 👉 sum([10,20])/2 = 15 Lookup / Searching 🔍 • in → Check existence 👉 5 in [1,2,5] = True • list.index(value) → Position of value 👉 [10,20,30].index(20) = 1 • Dictionary lookup 👉 data = {"name": "John", "age": 25} data["name"] # John Logical Operations 🧠 • if condition: → Decision making 👉 if x > 10: print("High") else: print("Low") • and → All conditions true • or → Any condition true • not → Reverse condition Text (String) Functions 🔤 • len(text) → Length 👉 len("hello") = 5 • text.lower() → Lowercase • text.upper() → Uppercase • text.strip() → Remove spaces 👉 " hi ".strip() = "hi" • text.replace(old, new) 👉 "hi".replace("h","H") = "Hi" • String concatenation 👉 "Hello " + "World" Date Time Functions 📅 • from datetime import datetime • datetime.now() → Current date time • Extract values: now = datetime.now() now.year now.month now.day Math Functions ➗ • import math • math.sqrt(x) → Square root • math.ceil(x) → Round up • math.floor(x) → Round down • abs(x) → Absolute value Conditional Aggregation (Like Excel SUMIF) ⚡ • Using list comprehension nums = [10, 20, 30, 40] sum(x for x in nums if x > 20) # 70 • Count condition len([x for x in nums if x > 20]) # 2 Pro Tip for Data Analysts 💡 👉 For real-world work, use libraries: pandas & numpy Example: import pandas as pd df["salary"].mean() Python Resources: https://whatsapp.com/channel/0029VaiM08SDuMRaGKd9Wv0L Double Tap ♥️ For More