Artificial Intelligence & ChatGPT Prompts: post #2399 โ€” TG.ME

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
โค1
August 28, 2026 363 2