Tone Adjuster
Paste an email draft and let AI rewrite it for professional or friendly tones.
- Prompt frameworks
- Voice consistency
Before you teach AI to think, you must learn to think like a coder. Master the foundations of the $2 Trillion economy.
Python powers 90% of today's AI research. It's simple, powerful, and universal. Master these 4 blocks to build anything.
Containers for your data.
Reusable mini-programs.
Automate repetitive tasks.
Structured data storage.
APIs are the bridges. They let your Python code talk to world-class models like DALL-E and Gemini.
Python Script
OpenAI / Anthropic
Mini Projects
Hands-on builders to internalize every Python + AI concept.
Paste an email draft and let AI rewrite it for professional or friendly tones.
Simplify quantum physics or AI concepts using natural storytelling.
Generate 3 platform-ready posts with hooks, CTAs, and trending tags.
Turn feature lists into persuasive marketing descriptions instantly.
Building the core blocks of your AI applications
Variables are labels for boxes holding information. We use int, float, str, and bool to store different data shapes.
my_age = 30
pi_value = 3.14159
user_name = "Alex"
is_learning = True
print(f"Name: {user_name} ({type(user_name)})")
print(f"Age: {my_age}, Learn: {is_learning}")
A list is an ordered, changeable collection. Access items by index (starts at 0).
fruits = ["apple", "banana", "cherry"]
print("Initial:", fruits)
fruits.append("orange")
print("First Item:", fruits[0])
fruits.remove("banana")
print("Modified:", fruits)
A curated guide to mastering technical logic
Using Python's slice syntax [::-1] to efficiently return a reversed string.
def reverse_string(s):
return s[::-1]
print(f"'hello' reversed: {reverse_string('hello')}")
Checking if a string reads the same forwards and backwards after cleaning non-alphanumeric characters.
def is_palindrome(s):
cleaned = "".join(c.lower() for c in s if c.isalnum())
return cleaned == cleaned[::-1]
print(f"Is 'A man, a plan, a canal: Panama' a palindrome? {is_palindrome('A man, a plan, a canal: Panama')}")
Two strings are anagrams if their sorted characters match. We ignore case and spaces.
def are_anagrams(s1, s2):
return sorted(s1.lower().replace(" ","")) == sorted(s2.lower().replace(" ",""))
print(f"Are 'silent' and 'listen' anagrams? {are_anagrams('silent', 'listen')}")
Calculating the expected sum using n * (n + 1) // 2 and subtracting the actual sum.
def find_missing(nums):
n = len(nums)
expected = n * (n + 1) // 2
return expected - sum(nums)
print(f"Missing in [3, 0, 1]: {find_missing([3, 0, 1])}")
Using a Set to track seen items for O(n) lookups.
def find_duplicates(nums):
seen = set()
dupes = set()
for n in nums:
if n in seen: dupes.add(n)
else: seen.add(n)
return list(dupes)
print(f"Duplicates: {find_duplicates([1, 2, 3, 2, 1, 5])}")
Finding indices of two numbers adding to target using a dictionary lookup for the complement.
def two_sum(nums, target):
seen = {}
for i, num in enumerate(nums):
comp = target - num
if comp in seen: return [seen[comp], i]
seen[num] = i
return []
print(f"Indices for Target 9: {two_sum([2, 7, 11, 15], 9)}")
Using two pointers to merge without a full re-sort for efficiency.
def merge_lists(l1, l2):
res = []
i = j = 0
while i < len(l1) and j < len(l2):
if l1[i] < l2[j]: res.append(l1[i]); i += 1
else: res.append(l2[j]); j += 1
res.extend(l1[i:]); res.extend(l2[j:])
return res
print(f"Merged: {merge_lists([1, 2, 4], [1, 3, 4])}")
Testing modulo logic: Multiples of 3, 5, or both.
def fizzbuzz(n):
res = []
for i in range(1, n+1):
if i % 15 == 0: res.append("FizzBuzz")
elif i % 3 == 0: res.append("Fizz")
elif i % 5 == 0: res.append("Buzz")
else: res.append(str(i))
return res
print(fizzbuzz(15))
Comparing iterative vs recursive approaches for generating the n-th number.
def fib(n):
a, b = 0, 1
for _ in range(n): a, b = b, a + b
return a
print(f"10th Fibonacci: {fib(10)}")
Checking divisors up to the square root of n for optimized performance.
import math
def is_prime(n):
if n < 2: return False
for i in range(2, int(math.sqrt(n)) + 1):
if n % i == 0: return False
return True
print(f"Is 29 Prime? {is_prime(29)}")
Grouping words that share characters by using sorted strings as dictionary keys.
def group_anagrams(strs):
m = {}
for s in strs:
key = "".join(sorted(s))
if key not in m: m[key] = []
m[key].append(s)
return list(m.values())
print(group_anagrams(["eat", "tea", "tan", "ate"]))
Designing a class to support push, pop, and peek using an internal list.
class Stack:
def __init__(self): self.items = []
def push(self, i): self.items.append(i)
def pop(self): return self.items.pop() if self.items else None
def peek(self): return self.items[-1] if self.items else None
s = Stack()
s.push(10); s.push(20)
print(f"Peek: {s.peek()}, Popped: {s.pop()}")
Creating new lists from existing ones in a single line using [expression for item in list if condition].
nums = [1, 2, 3, 4, 5, 6]
squares_of_evens = [n*n for n in nums if n % 2 == 0]
print(f"Result: {squares_of_evens}")
Using *args for extra positional items and **kwargs for extra named parameters.
def demo(*args, **kwargs):
print(f"Positional: {args}")
print(f"Keyword: {kwargs}")
demo(1, 2, name="Alice", age=30)
Defining a constructor and class methods to manage object state.
class Car:
def __init__(self, make, model, year):
self.make, self.model, self.year = make, model, year
def describe(self):
return f"{self.year} {self.make} {self.model}"
my_car = Car("Toyota", "Camry", 2020)
print(my_car.describe())
Determining minimum guards needed by calculating overlapping shift depth.
def min_guards(shifts):
events = []
for s in shifts:
events.append((s['start'], 1))
events.append((s['end'], -1))
events.sort(key=lambda x: (x[0], x[1]))
mx, curr = 0, 0
for _, delta in events:
curr += delta
mx = max(mx, curr)
return mx
shifts = [{"start": 100, "end": 400}, {"start": 300, "end": 600}]
print(f"Guards required: {min_guards(shifts)}")
Calculating moving averages and max subarray sums using class-based logic.
class WindowProcessor:
def __init__(self, data, size):
self._data, self.s = data, size
def get_moving_average(self):
res = []
for i in range(len(self._data) - self.s + 1):
res.append(sum(self._data[i:i+self.s])/self.s)
return res
proc = WindowProcessor([1, 3, 2, 6, -1, 4, 1, 8, 2], 5)
print(f"Moving Averages: {proc.get_moving_average()}")