Basics
Values and types
Section titled “Values and types”Taipan’s basic types are int (64-bit), float, bool, str and None. Every value has a type, known when the program compiles.
let answer = 42let ratio = 0.75let ready = Truelet name = "Taipan"print(answer, ratio, ready, name)42 0.75 True Taipanlet, var and const
Section titled “let, var and const”letdeclares a name that can’t be reassigned.vardeclares one that can.constdeclares a top-level constant, visible everywhere, whose value is computed from literals.
const LIMIT = 3
var total = 0for i in range(LIMIT): total += ilet message = f"total is {total}"print(message)total is 3A type annotation is optional on let and var, and needed when the initializer doesn’t say enough, as with an empty list:
var names: list[str] = []names.append("ada")let limit: float = 10print(names, limit)["ada"] 10.0Each block has its own scope. A name is visible from its declaration to the end of its block, and a name in an inner block can’t shadow one from an outer block.
Numbers
Section titled “Numbers”int arithmetic is checked: overflow raises OverflowError rather than wrapping. / always gives a float, // and % floor as in Python, and ** is a power.
print(7 / 2, 7 // 2, -7 // 2, 7 % 3, 2 ** 10)print(1_000_000 * 3, 0.1 + 0.2)print(int(3.9), float(2), round(2.5), abs(-4))3.5 3 -4 1 10243000000 0.300000000000000043 2.0 2 4An int is accepted where a float is expected. No other conversion is implicit.
Strings
Section titled “Strings”Strings are immutable Unicode text, in "…" or '…'. F-strings take expressions and Python’s format specs:
let lang = "taipan"let version = 0.4print(lang.upper(), len(lang), lang[0], lang[-2:])print(f"{lang!r} {version:.2f} {42:>5} {1234567:,}")print(f"{lang=}")print(", ".join(["a", "b", "c"]), "a,b".split(","))TAIPAN 6 t an"taipan" 0.40 42 1,234,567lang="taipan"a, b, c ["a", "b"]Inside containers, and with !r, strings are written with double quotes.
Conditions
Section titled “Conditions”if, elif, else and while work as in Python, and a condition must be a bool. and, or and not take bools too.
def describe(n: int) -> str: if n < 0: return "negative" elif n == 0: return "zero" elif n % 2 == 0 and n < 100: return "small and even" else: return "other"
for n in [-5, 0, 8, 7]: print(n, describe(n))-5 negative0 zero8 small and even7 otherComparisons don’t chain: write 0 < x and x < 10 rather than 0 < x < 10.
for goes over anything iterable: lists, strings, dicts, ranges and generators. while repeats while its condition holds, and break and continue work as in Python.
for i in range(10, 0, -3): print(i, end=" ")print()
var n = 27var steps = 0while n != 1: if n % 2 == 0: n = n // 2 else: n = 3 * n + 1 steps += 1print(steps)10 7 4 1111Printing and input
Section titled “Printing and input”print takes Python’s sep, end, file and flush arguments; print(x, file=sys.stderr) writes to standard error, after import sys. input() reads a line from standard input.
print("a", "b", sep="-")print("no newline", end="")print()a-bno newlineThere’s no conditional expression (a if c else b). Use an if statement, or a match expression:
let n = 7let parity = match n % 2 == 0: True: "even" False: "odd"print(parity)oddNext: Collections.
© 2026 Discover Edge, LLC · Taipan is released under the MIT License.