> For the complete documentation index, see [llms.txt](https://python-self-driving.gitbook.io/self-driving/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://python-self-driving.gitbook.io/self-driving/python/math-in-python.md).

# Math in Python

## The math library contains many methods including a method that ouputs the value of pi.

```python
import math

radius        = 10.0
diameter      = 2 * radius
circumference = 2 * math.pi * radius
area          = math.pi * radius ** 2

print("Radius is", radius)
print("Diameter is", diameter)
print("Circumference is", circumference)
print("Area is", area)
```

```
Radius is 10.0
Diameter is 20.0
Circumference is 62.83185307179586
Area is 314.1592653589793
```

#### isinstance() function <a href="#isinstance-function" id="isinstance-function"></a>

In the next code cell, you will see how the isinstance() function works.

The isinstance() function checks to see if a variable holds a certain type of value like an integer, float, string, etc.

```python
sqr_root_2 = math.sqrt(2)
is_sqr_root_2_an_integer = isinstance(sqr_root_2, int)
print("Is square root two an integer?", is_sqr_root_2_an_integer)

is_sqr_root_2_a_float = isinstance(sqr_root_2, float)
print("Is square root two a float?", is_sqr_root_2_a_float)
```

```
Is square root two an integer? False
Is square root two a float? True
```
