Mojo as a Python Superset
Familiar syntax with new performance powers.
Mojo as a Python Superset is a free Mojo Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Mojo Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Python, Plus More
Mojo is built as a superset of Python: the Python you know is a starting point, with new powers layered on top. 🧩
Syntax You Recognize
Indentation, colons, and clean keywords stay the same. A Mojo for loop reads just like its Python cousin.
for i in range(3):
print(i)Same Familiar Functions
Everyday tools like print and range carry straight over, so your existing Python habits keep working in Mojo.
print("Mojo feels familiar")A Gradual On-Ramp
You can start writing Python-flavored code today and adopt Mojo's faster features gradually, at your own pace.
New Keyword: var
Mojo adds var to declare a variable explicitly, which makes your intent clear and helps the compiler optimize.
var count = 10Optional Type Annotations
You can tag values with a type like Int. This is optional Python syntax in Mojo that unlocks real speed.
var score: Int = 100Two Kinds of Functions
Mojo keeps Python's def but adds fn for stricter, faster functions. You choose how much rigor you want.
fn add(a: Int, b: Int) -> Int:
return a + bStructs for Speed
Beyond classes, Mojo offers the struct: a fast, statically typed way to bundle data and behavior together.
struct Point:
var x: Int
var y: IntSuperset, Growing Toward Full
Mojo aims to eventually run all valid Python, while today it already covers a familiar, useful subset plus its own features.
Keep Your Mental Model
Because the foundation is Python, your existing mental model transfers. You add new tools rather than relearning everything.
Familiar Feel, New Ceiling
The big idea: Mojo feels like Python but raises the performance ceiling far above what pure Python can reach. ⚡
Quick Check
Recall what being a Python superset really gives you.
Recap
You saw Mojo keep Python's syntax while adding var, type annotations, fn, and struct, giving you a smooth upgrade path. 🎯
Frequently asked questions
Is the “Mojo as a Python Superset” lesson free?
Yes — the full text of “Mojo as a Python Superset” is free to read here on the web, and the Mojo Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Mojo Academy course, upgrade to CoddyKit PRO.
What will I learn in “Mojo as a Python Superset”?
Familiar syntax with new performance powers. You practise Mojo Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Mojo Academy?
No prior experience is required. Mojo Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Mojo as a Python Superset” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Mojo Academy lesson?
Yes. Every Mojo Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- What Problem Does Mojo Solve?
- Mojo as a Python Superset
- Where Mojo Fits in the AI Stack
- Compiled Speed, Python Feel