First Steps: Computer Science

Here's how you build code editors that grade themselves, draw with turtle graphics, hook up SQL databases, ask matching quiz questions, drop in ready-made plugins like the Dijkstra visualizer, and build your own plugins.

Even or odd

A number is even if dividing it by 2 leaves no remainder — in Python, n % 2 == 0.

Write a function is_even(n) that returns True if n is even, False otherwise.

PythonLoading editor…
def is_even(n):
    # your code here
    pass

That's the whole thing. The editor block is where students write and run code — give it an id. The python-check block is invisible to students; it only fires when they click "Check", and for has to match the editor's id exactly, or your check silently does nothing. Whatever you write in assert is what gets graded — points="10" is the max if everything passes.

Want it to stay silent during a real exam instead of showing pass/fail right away? Add exam to the editor.

That covers a first exercise. There's more — turtle graphics, multiple files, SQL with a database attached — under Code Editors & Scoring once you're ready.