Coding Python
Home›Python Coding Games›Operator Arcade

Operator Arcade — Numbers & operators

Six machines, each with a number to hit and a restricted set of digits and operators to hit it with.

Level 1

Checks
    Your PythonPython 3
    1

    How to play

    Each level names a target and sometimes restricts which characters you may use. Write the expression, press Run, and the scoreboard shows what you produced next to what was wanted. The restriction is the teaching device: when you are only allowed 2, 1, 0 and *, you cannot avoid discovering **.

    What each level teaches

    1. Hit 24 — an expression is evaluated first, then stored.
    2. Three kinds of division — the level most people need. 17 / 5 is 3.4, 17 // 5 is 3, and 17 % 5 is 2. Three different questions, three different operators.
    3. Reach 1024 — ** for powers, and the fact that it binds more tightly than anything else.
    4. Order matters — precedence. 2 + 3 * 4 is 14, not 20. Brackets are how you say what you meant.
    5. True or false — comparisons produce real boolean values you can store, combine and reuse. Python also allows the chained form 1 <= x <= 10, which most languages do not.
    6. Till receipt — round() versus int(). int() truncates towards zero, which quietly loses money if you use it to round a price.

    Why // and % matter more than they look

    Together they answer "how many whole groups, and what is left over" — which is how you convert seconds into minutes and seconds, pick a colour from a list that is shorter than your loop, lay items out in rows, or test whether a number is even. % in particular appears in almost every beginner exercise, and it is the operator people most often skip past in a tutorial and then fail to recognise later.

    One thing worth knowing about floats

    Level 6 uses 19.999 deliberately. Multiply it by 100 and Python gives you 1999.8999999999999, not 1999.9, because binary floating point cannot represent most decimal fractions exactly. round() hides it here, but in real money code the fix is to work in whole cents as integers, or to use the decimal module. The full explanation is in the tutorial on Python numbers and operators.

    Practise numbers & operators on your phone — the Coding Python app runs real Python 3 on your phone, with examples, quizzes and challenges built in.
    Get it free

    Frequently asked questions

    What is the difference between / and // in Python?

    / is true division and always returns a float, even when it divides exactly: 10 / 2 is 5.0. // is floor division and returns the result rounded down towards negative infinity, keeping the int type when both operands are ints: 10 // 3 is 3.

    What does % do in Python?

    It gives the remainder after division. 17 % 5 is 2. It is most often used to test divisibility — n % 2 == 0 means n is even — and to wrap a counter around a fixed range.

    Why is 2 + 3 * 4 equal to 14?

    Because multiplication is evaluated before addition, exactly as in ordinary arithmetic. Brackets override that: (2 + 3) * 4 is 20.

    Does round() always return an integer?

    No. round(x) with one argument returns an int, but round(x, 2) with a number of decimal places returns a float — so round(19.999, 2) is 20.0, not 20.

    Is this operators game suitable for complete beginners?

    Yes. Level 1 needs one multiplication. The later levels assume only what the earlier ones taught.

    Keep going

    ← All Python coding games  Read the tutorial →

    Take the games with you

    Coding Python packs a real Python 3 compiler, 30 example programs, 112 quiz questions and 12 self-checking challenges into one free Android app.

    Get it on Google Play
    Coding Python app icon