# Calculator Tools (/examples/tools/calculator-tools)



```python title="calculator_tools.py"
"""
Calculator Tools
=============================

Demonstrates calculator tools.
"""

from agno.agent import Agent
from agno.tools.calculator import CalculatorTools

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------


# Example 1: Include specific calculator functions for basic operations
basic_calc_agent = Agent(
    tools=[CalculatorTools(include_tools=["add", "subtract", "multiply", "divide"])],
    markdown=True,
)

# Example 2: Exclude advanced functions for simple use cases
simple_calc_agent = Agent(
    tools=[CalculatorTools(exclude_tools=["factorial", "is_prime", "exponentiate"])],
    markdown=True,
)

# Example 3: Full calculator functionality (default)
agent = Agent(
    tools=[CalculatorTools()],
    markdown=True,
)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    simple_calc_agent.print_response(
        "What is 10*5 then to the power of 2, do it step by step"
    )
```

The run uses `simple_calc_agent`, which excludes `exponentiate`. It can still square 50 by calling `multiply(50, 50)`. To demonstrate the power tool directly, run the prompt on `agent`, whose toolkit includes it.

## Run the Example [#run-the-example]

<Steps>
    <Step title="Set up your virtual environment">
      <CodeBlockTabs defaultValue="Mac">
        <CodeBlockTabsList>
          <CodeBlockTabsTrigger value="Mac">
            Mac
          </CodeBlockTabsTrigger>

          <CodeBlockTabsTrigger value="Windows">
            Windows
          </CodeBlockTabsTrigger>
        </CodeBlockTabsList>

        <CodeBlockTab value="Mac">
          ```bash
          uv venv --python 3.12
          source .venv/bin/activate
          ```
        </CodeBlockTab>

        <CodeBlockTab value="Windows">
          ```bash
          uv venv --python 3.12
          .venv\Scripts\activate
          ```
        </CodeBlockTab>
      </CodeBlockTabs>
    </Step>

  <Step title="Install dependencies">
    ```bash
    uv pip install -U agno openai
    ```
  </Step>

  <Step title="Export your OpenAI API key">
    <CodeBlockTabs defaultValue="Mac/Linux">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="Mac/Linux">
          Mac/Linux
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="Windows">
          Windows
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="Mac/Linux">
        ```bash
        export OPENAI_API_KEY="your_openai_api_key_here"
        ```
      </CodeBlockTab>

      <CodeBlockTab value="Windows">
        ```bash
        $Env:OPENAI_API_KEY="your_openai_api_key_here"
        ```
      </CodeBlockTab>
    </CodeBlockTabs>
  </Step>

  <Step title="Run the example">
    Save the code above as `calculator_tools.py`, then run:

    ```bash
    python calculator_tools.py
    ```
  </Step>
</Steps>

Full source: [cookbook/91\_tools/calculator\_tools.py](https://github.com/agno-agi/agno/blob/8f36eaf2d18e91afa7b327eec66a3cd3685dcb87/cookbook/91_tools/calculator_tools.py)
