Lesson goal: Taking square roots

Previous: Using Pi on the computer | Home | Next: Random numbers

Programming languages often have built in mathematical functions, that do much more than add, subtract, multiply and divide. In this lesson, we'll look at two, the square root.

If you recall, the square root of some number is another number, when multipilied by itself, gives the original number. So for example, the square root of 25 is 5, since $5\times 5=25$, and the square root of 9 is 3 (since $3\times 3=9$). In math sense, this would be written as $\sqrt{25}=5$ and $\sqrt{9}=3$.

Here is how the computer will compute a square root (note that sqrt is short for "SQuare RooT"):
Move the mouse over a dotted box for more information.

The prefix of math. means that sqrt is included in the "math" library that the computer knows about.

Now you try. Use the print statement to find the square root of some numbers.

Type your code here:

See your results here: