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
1August 28, 2026 365 2