Kōdlet User Guide

Everything you need to know to write, run, and share code on kōdlet.

Project Types

When you create a new kodlet, choose your project type:

TypeWhat you get
PythonA main.py file. Add more .py files, data files (.csv, .txt, .json, etc.), and import them normally.
Webindex.html, style.css, and script.js files. The output pane renders the page live.

Writing and Running Code

Using input()

The input() function works in Python kodlets. When your program calls input(), a terminal strip appears below the output and waits for you to type. Press Enter to submit.

name = input("What is your name? ")
print("Hello,", name)

Keyboard Shortcuts

ActionShortcut
RunCtrl+Enter / Cmd+Enter
Toggle commentCtrl+/ / Cmd+/
Indent selectionTab
Unindent selectionShift+Tab

Saving and Sharing

Embedding

Embed code is available for public kodlets only. Copy the iframe snippet from the Embed menu and paste it into any webpage or LMS.

The embedded view lets visitors read and run the code. They can edit locally in their browser but changes are not saved — your original is unaffected. Logged-in users can click Remix to save their own copy.

For stateless embeds (no saved kodlet required):

https://kodlet.io/embed/inline?lang=python&code=BASE64_ENCODED_CODE

Available Python Libraries

Standard library

All standard Python modules work: math, random, statistics, datetime, time, calendar, collections, itertools, functools, json, csv, re, io, string, sys, copy, enum, dataclasses, pathlib, os.path, and more.

Built into Kōdlet

LibraryWhat it's for
turtleTurtle graphics — move a turtle around a canvas to draw shapes and animations
imageImage processing — open, modify, and display image files (cImage / ThinkCSpy compatible)

Loaded automatically when imported

LibraryWhat it's for
matplotlib / matplotlib.pyplotCharts, graphs, and plots

Also available (via Pyodide)

LibraryWhat it's for
numpyNumerical computing — arrays, linear algebra, math operations

Kōdlet runs Python entirely in your browser via Pyodide. If there's a library you'd like supported, contact us.

Turtle Graphics

Kōdlet's turtle module is compatible with Python's standard turtle library and with Trinket.io turtle programs. Supported features include:

Programs that use onkey() or ontimer() without calling mainloop() explicitly will work correctly — Kōdlet starts the event loop automatically.

Image Processing

The image module is compatible with the cImage library used in How to Think Like a Computer Scientist (Runestone / ThinkCSpy).

import image
img = image.Image("photo.jpg")   # file must be in the editor's file list
for row in range(img.getHeight()):
    for col in range(img.getWidth()):
        p = img.getPixel(col, row)
        img.setPixel(col, row, image.Pixel(p.getRed(), 0, 0))
win = image.ImageWin()
img.draw(win)

Importing from Trinket

If you have existing projects on Trinket.io, you can import them all at once:

  1. Log in to Trinket.io and go to your account settings.
  2. Download your Trinket export ZIP file.
  3. On Kōdlet, go to /import and upload the ZIP.
  4. All your trinkets are imported as kodlets, including any images and assets.

Python and HTML/CSS trinkets are fully supported. PyGame trinkets are imported as Python projects with a note that PyGame is not yet supported.

Tips