Taz

All Taz Challenges

Teach it odd and even

You will use the remainder after division by two to label integers. One successful example is a start, but testing zero, odd and even values gives a better check.

Grown-up needed: yes for choosing and supervising the coding environment

The film says 'Taz, on the Code tab'. In Taz today, choose Make, then Code, and pick Python.

What you need

The rule

It must get every number right.

How to do it

  1. Set n = 7 at the top of a small Python program.
  2. Write if n % 2 == 0: beneath it.
  3. Indent print("even") under that condition.
  4. Write else: without indentation and indent print("odd") beneath it.
  5. Predict and run the result for seven.
  6. Repeat with zero, eight and minus three.

Why it works

The remainder operator % gives the remainder for this division. Integers divisible by two have remainder zero and are even; other integers are odd. The conditional chooses one branch, so the program prints only one label for its current input. Zero is even because zero equals two times zero. Negative integers can also be classified. This rule applies to integers, and feeding unrelated text or general fractional values into the example is outside the stated whole-number task.

Make it harder

Ask Taz

Ask Taz

The coding part of Taz is the Maker Studio.

For grown-ups

Choose and supervise the coding environment. The film names a Taz Code tab. In Taz today that is the Maker Studio: choose Make, then Code, and pick Python. Use ordinary sample words and numbers without personal details. Ask at dinner: “Which prediction did you check, and what change in the instructions would change that output?”

Taz is an AI and can be wrong, so stay close by. Read how safety works on Taz.

Show us yours

Film your hands and what you made, not your face or name. Ask a grown-up before posting anywhere else.

Questions parents ask

Can we begin without running code?

Yes. Write the predicted output on paper and trace the steps together. That gives you a comparison to use when a grown-up-approved Python environment is available. A prediction remains a prediction until you check the actual instructions and result.

What if an error appears?

Read the message with a grown-up and compare spelling, punctuation and indentation with the steps. Change one thing at a time and keep a note of what happened. An error is useful evidence about the instructions, not a judgement about the child.

Must we share the result?

No. Discussing the output at home is enough. Follow the privacy line above for optional online sharing.

More to try

See all Taz Challenges, or look through the science labs. One place for every why. Ask for early access at aitaz.com