Python
Readable, batteries-included, runs in your browser via Pyodide.
About Python
Python is a high-level, dynamically typed language designed for readability. It's used everywhere — web, data science, scripting, automation, AI. In this course, your code runs FOR REAL inside your browser using Pyodide (CPython compiled to WebAssembly).
Quick-reference cheat sheet
# Python cheat-sheet (the bits you'll need)
# Comments start with #
print("hello") # output
x = 42 # variables — no type annotation needed
name = "ada" # strings: "..." or '...'
pi = 3.14 # floats
ok = True # booleans (True/False)
nothing = None # null
# f-strings
print(f"x={x}, name={name}")
# Math
2 + 3 # 5
2 ** 8 # 256 (power)
7 // 2 # 3 (integer division)
7 % 2 # 1 (modulo)
# Conditions (indentation matters!)
if x > 0:
print("positive")
elif x == 0:
print("zero")
else:
print("negative")
# Loops
for i in range(5): # 0..4
print(i)
while x > 0:
x -= 1
# Lists / tuples / dicts / sets
nums = [1, 2, 3]
nums.append(4)
point = (1, 2)
person = {"name": "ada", "age": 36}
unique = {1, 2, 3}
# Comprehensions
squares = [n*n for n in range(5)]
evens = {n for n in nums if n % 2 == 0}
lookup = {n: n*n for n in range(5)}
# Functions
def add(a, b):
return a + b
# Reading input from stdin
line = input() # one line of input
n = int(input()) # parse to int
Tasks
- 01introHello, World!Print exactly: Hello, World!
- 02introGreet the userRead a name from stdin and print: Hello, <name>!
- 03introAdd two numbersRead two ints on separate lines, print their sum.
- 04introArea of a rectangleRead width and height, print area.
- 05introCelsius → FahrenheitConvert temperature.
- 06easyFizzBuzzClassic FizzBuzz from 1 to 15.
- 07easyReverse a stringReverse the input line.
- 08easySum of evensSum all even numbers from 1 to N.
- 09easyMax of threePrint the largest of three numbers.
- 10easyCount vowelsCount vowels in a line.
- 11easyAverage of a listPrint the average of space-separated numbers.
- 12mediumPalindrome checkPrint "yes" if the input is a palindrome, otherwise "no".
- 13mediumFibonacciPrint the first 10 Fibonacci numbers, comma-separated.
- 14mediumIs it prime?Print "prime" or "not prime".
- 15mediumList comprehension: squaresPrint squares of 1..10 space-separated.
- 16mediumLetter frequencyCount occurrences of letter 'a' in a string.
- 17mediumFactorialCompute n! for n on stdin.
- 18mediumGreatest common divisorGCD of two integers.
- 19mediumSort wordsSort the words of a line alphabetically.
- 20mediumAnagram checkTwo words on two lines — anagrams?
- 21mediumSecond largestFind the second-largest distinct number.
- 22mediumDecimal → binaryConvert N to binary.
- 23hardMost common wordFind the most frequent word in a sentence.
- 24hardTranspose a matrixTranspose a 3x3 matrix from stdin.
- 25hardRecursive list sumRecursively sum a list.
- 26hardParse JSONParse a JSON object and print a value.
- 27hardClass: BankAccountDefine a class with deposit/withdraw.
- 28hardWrite a decoratorA decorator that doubles a function's return value.
- 29hardGenerator: fibonacciDefine a generator yielding fibonacci numbers.
- 30hardROT13 cipherApply ROT13 to input.
- 31easyStrip & title-caseClean up a messy name string.
- 32easyMiddle slicePrint everything except first and last element.
- 33easyInventory totalSum dictionary values.
- 34easyComma codeJoin a list with commas and 'and'.
- 35mediumCollatz sequencePrint the Collatz sequence until it reaches 1.
- 36mediumStreak finderDetect a run of 6 identical chars.
- 37mediumRegex: extract phoneFind a US-style phone number in text.
- 38mediumRegex: extract emailsFind all emails in text.
- 39mediumStrong password checkValidate password strength.
- 40mediumRight-aligned tableFormat a column-aligned table.
- 41mediumASCII zigzagPrint 5 lines of a zigzag wave.
- 42mediumCSV: sum columnParse CSV from stdin and sum a column.
- 43mediumJSON: pretty print keysList sorted keys of a JSON object.
- 44mediumDays between datesCompute date difference in days.
- 45hardRoman numeral converterConvert an integer (1..3999) to Roman numerals.
- 46hardCaesar cipher (shift N)Encrypt with arbitrary shift.
- 47hardMini key-value storeImplement a tiny stdin-driven KV store.
- 48hardBullet pointerAdd * to start of every input line.
- 49hardPicture grid (rotate 90°)Rotate an ASCII picture 90° clockwise.
- 50hardMad Libs replacerReplace ADJECTIVE/NOUN/VERB placeholders.
- 51hardRegex strip functionStrip given characters using regex.
- 52hardScore a dice rollScore a Yahtzee-style roll.
- 53hardSudoku row validatorCheck if 9 numbers form a valid Sudoku row.
- 54hardBalanced bracketsCheck (), [], {} are balanced.
- 55hardSpreadsheet totalsAggregate sales by product (ATBS Ch.13).
- 56hardGreedy coin changeMake change with fewest US coins.
- 57hardGame of Life: one stepCompute next generation of a 5x5 grid.
- 58easyDecode an intercepted base64 blobRead one base64 string from stdin, print its decoded ASCII value.
- 59easyHex dump → readable stringConvert a hex-encoded ASCII string from stdin into the original text.
- 60easyHash a candidate password (MD5)Read a password from stdin and print its MD5 hex digest.
- 61easyFingerprint a token (SHA-256)Print the SHA-256 hex digest of the stdin string.
- 62easyDefang malicious URLsReplace 'http' with 'hxxp' and '.' with '[.]' on every URL.
- 63mediumSpot dropped malware by extensionCount how many filenames in stdin end with a suspicious extension.
- 64mediumMap ports to common servicesFor each port number in stdin, print the well-known service name (or 'unknown').
- 65mediumHow many usable hosts in this CIDR?Read an IPv4 CIDR like 192.168.1.0/24 and print the number of usable host addresses.
- 66mediumFailed-login frequency per IPFrom sshd 'Failed password ... from <ip>' lines, print 'ip count' sorted by count desc, then ip asc.
- 67mediumFlag brute-force IPsPrint every IP with at least 3 failed-login attempts, sorted ascending.
- 68mediumCatch obvious SQL injectionCount how many input lines contain an obvious SQLi pattern.
- 69mediumClassify visitors by OSFrom a list of User-Agent strings, output Windows/Linux/Mac/Other counts in that fixed order.
- 70mediumCrack a Caesar cipherTry every shift 1..25 and print the decryption that contains the word 'the'.
- 71hardTiny dictionary MD5 crackerGiven a target MD5 and a wordlist on stdin, print the matching word (or 'not found').
- 72hardRecover a single-byte XOR keyBrute-force every byte key, find the one whose decryption is printable English with 'the '.
- 73hardDecode a JWT (no signature check)Split a JWT, decode header + payload (base64url), print 'alg=...' and 'sub=...'.
- 74hardBuild a XOR + base64 payloadRead one line, XOR every byte with 0x42, print the result base64-encoded.
- 75hardTriage an access logParse 'METHOD path status' lines, print totals + 2xx/4xx/5xx + most-hit path.
- 76hardRoll up a port scan into a reportGroup 'host port status' lines, print 'host: p1,p2' for hosts with at least one open port.
- 77hardExtract a hidden LSB messageFrom a sequence of integers, take each LSB and assemble bytes (MSB-first) to recover ASCII.
- 78hardBoss fight: end-to-end brute-force triageFrom sshd logs, find IPs with ≥3 failures, SHA-1 hash each, print 'ip:hash' sorted by IP.
- 79easyAutomation: strip trailing whitespaceRead every line from stdin and print it back without trailing spaces or tabs.
- 80easyAutomation: batch-rename with date prefixPrefix every filename with the date from line 1 — e.g. 2024-01-15_report.txt.
- 81easyAutomation: find TODO line numbersPrint 1-indexed line numbers of every line containing TODO.
- 82easyAutomation: collapse consecutive blank linesCollapse any run of blank lines into a single blank line.
- 83mediumAutomation: filter CSV by ageRead a CSV with header name,age and print names where age >= 18 (input order).
- 84mediumAutomation: extract ERROR log linesPrint only the log lines whose level is ERROR.
- 85mediumAutomation: filter log entries by time windowLine 1 is 'HH:MM HH:MM'. Print messages whose time falls inside (inclusive).
- 86mediumAutomation: parse URL query stringParse a query string and print key=value lines sorted by key.
- 87mediumAutomation: dedupe emails (case-insensitive)Print each email exactly once (lowercased), in first-seen order.
- 88mediumAutomation: build a markdown TOCTurn '#' and '##' headings into an indented bullet list.
- 89mediumAutomation: key/value lookupParse 'key: value' lines, then look up the key on the LAST line.
- 90mediumAutomation: TSV → JSON arrayConvert tab-separated values (with header) to a JSON array. Use sort_keys=True.
- 91mediumAutomation: log rotation planGiven log filenames, print 'old -> new' rotation mappings.
- 92hardAutomation: find duplicate files by hashGroup 'name,sha256' rows; print groups with 2+ files as 'hash: f1,f2,...'.
- 93hardAutomation: count overlapping meetingsCount pairs of meetings whose time ranges overlap.
- 94hardAutomation: validate CSV rowsPrint the 1-indexed data-row numbers of rows where email lacks @ or age is not 0-120 int.
- 95hardAutomation: render a {{var}} templateLine 1 is JSON vars. Replace {{key}} placeholders in the rest.
- 96hardAutomation: next cron-style run timeGiven the current HH:MM and a list of daily HH:MM jobs, print the next run.
- 97hardAutomation: extract unique emails from textFind all emails in messy text; print unique (lowercase) sorted alphabetically.
- 98hardAutomation: CSV pivot by categorySum amount per category and print 'category=total' sorted by total desc, alpha tiebreak.
- 99hardAutomation: top-3 products by revenueFrom a sales CSV, compute revenue=qty*price per product and print top 3.
- 100hardAutomation capstone: log reportBuild a 4-line summary from a structured log CSV.
