Lesson goal: The number $\pi$

Previous: Using absolute values | Home | Next: Using square roots

As introduced in a previous lesson, programming languages know how to "crunch" quite a bit of mathematics. In this case, let's study now to handle the famous number $\pi$ which is equal to 3.1415... . Here is the symbol to use for $\pi$ in your code:
Move the mouse over a dotted box for more information.

Notice the pi in the name. The prefix of math. means that pi is included in the "math" library that the computer knows about. This something.something notation is very common in computer programming.

Now you try. See if you can get $\pi$ to display. Try print(math.pi).

Type your code here:

See your results here:

Show a friend, family member, or teacher what you've done!

Here is a share link to your code:

Does your code work? Want to run it on your iPhone?

Here's your code:

  1. Use [Control]-[C] (Windows) or [⌘]-[C] (MacOS) to copy your code.

  2. Paste it using [Control]-[V] (Windows) or [⌘]-[V] (MacOS) into this page

  3. Then click the "Use on iPhone" button that you'll see.