Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/native/kernel/svc/tests/fixtures/code/short.txt # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / native / kernel / svc / tests / fixtures / code / short.txt` 33 lines ยท 844 bytes Raw Blame History 1 Here is a small calculator you can run with python3 calc.py. 2 3 ```python 4 # calc.py: a small calculator that reads one sum at a time. 5 import operator 6 7 OPS = {"+": operator.add, "-": operator.sub, "*": operator.mul, "/": operator.truediv} 8 9 10 def calculate(a, op, b): 11 if op not in OPS: 12 raise ValueError("unknown operator " + op) 13 if op == "/" and b == 0: 14 raise ZeroDivisionError("cannot divide by zero") 15 return OPS[op](a, b) 16 17 18 def main(): 19 print("Type a sum like 3 + 4, or q to quit.") 20 while True: 21 line = input("> ").strip() 22 if line in ("q", "quit"): 23 break 24 try: 25 a, op, b = line.split() 26 print(calculate(float(a), op, float(b))) 27 except (ValueError, ZeroDivisionError) as e: 28 print("Sorry:", e) 29 30 31 if __name__ == "__main__": 32 main() 33 ```