Everything you need to know to write, run, and share code on kōdlet.
When you create a new kodlet, choose your project type:
| Type | What you get |
|---|---|
| Python | A main.py file. Add more .py files, data files (.csv, .txt, .json, etc.), and import them normally. |
| Web | index.html, style.css, and script.js files. The output pane renders the page live. |
open("data.csv") to read a file you've added to the editor.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)
| Action | Shortcut |
|---|---|
| Run | Ctrl+Enter / Cmd+Enter |
| Toggle comment | Ctrl+/ / Cmd+/ |
| Indent selection | Tab |
| Unindent selection | Shift+Tab |
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
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.
| Library | What it's for |
|---|---|
turtle | Turtle graphics — move a turtle around a canvas to draw shapes and animations |
image | Image processing — open, modify, and display image files (cImage / ThinkCSpy compatible) |
| Library | What it's for |
|---|---|
matplotlib / matplotlib.pyplot | Charts, graphs, and plots |
| Library | What it's for |
|---|---|
numpy | Numerical 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.
Kōdlet's turtle module is compatible with Python's standard turtle library and with Trinket.io turtle programs. Supported features include:
forward, backward, left, right, goto, setx, sety, homepenup, pendown, pencolor, fillcolor, begin_fill, end_fill, pensize, speedshape, shapesize, showturtle, hideturtle, stampbgcolor, bgpic, title, setup, screensizeonkey, onkeypress, onkeyrelease, onclick, ontimerwriteTurtle(), turtles(), getturtle()mainloop, done, exitonclick, byePrograms that use onkey() or ontimer() without calling mainloop() explicitly will work correctly — Kōdlet starts the event loop automatically.
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)
If you have existing projects on Trinket.io, you can import them all at once:
Python and HTML/CSS trinkets are fully supported. PyGame trinkets are imported as Python projects with a note that PyGame is not yet supported.
\n and \t inside strings are highlighted in blue so they're easy to spot..py file in your project, use a standard import statement: import mymodule.