Skip to content
ExamplesOpen editor ↗

sq

→ sq()

Multiplies a number by itself — `sq(3)` is 3 × 3, which is 9.

sq(palo)

sq(3) is 9. sq(-3) is also 9, because two numbers below 0 multiplied together give a number above 0. So the result of sq is never below 0.

The name is left as it stands. sq is the short form of “square”, a piece of mathematical notation rather than an everyday word. In Botswana, mathematics is taught in English from the upper grades onward, and the notation a learner meets in class is the notation used here. See sqrt and pow, which travel with it.

Writing palo * palo is just as good — sq saves you repeating the variable name.

NameTypeDescription
palopaloThe number to multiply by itself.
Growing fast — sq against a straight line
tiro setaLoeto() {
  thalaKanefase(400, 400);
  bokamorago(242);
  tlogelaMothalo();

  gopheta (diri i = 0; i < 20; i = i + 1) {
    metlha tekanyo = selekanyo(i, 0, 19);

    // Tolamo — e gola ka tekanyo e le nngwe
    tlatsaMmala(200, 205, 215);
    thalaKhutlonne(20 + i * 19, 360 - tekanyo * 300, 8, tekanyo * 300);

    // sq — e simolola ka bonya, e bo e tlolela kwa godimo
    tlatsaMmala(60, 130, 210);
    thalaKhutlonne(28 + i * 19, 360 - sq(tekanyo) * 300, 8, sq(tekanyo) * 300);
  }
}

sqrt, pow, exp, bokgakalaPalo