# Python examples

These examples use the [Investment Growth Calculator](https://www.equalto.com/suresheet/view/abc7cbef-2491-4787-94f8-6542fab12a4e) SureSheet, and do not depend on any third-party libraries.

### Simple example

```python
import urllib.request
from urllib.parse import quote
import json
workbook_id = "abc7cbef-2491-4787-94f8-6542fab12a4e"
inputs = json.dumps({"Sheet1":{"C6":25000}})
outputs = json.dumps({"Sheet1":["C13"]})
simulate_url = f"https://www.equalto.com/suresheet/api/v1/simulate/{workbook_id}?inputs={quote(inputs)}&outputs={quote(outputs)}"

with urllib.request.urlopen(simulate_url) as response:
    results = json.loads(response.read())

print(results)

```

Should print:

```json
{'Sheet1': {'C13': 50783.31719489607}}
```

### Advanced example with ranges

```python
import urllib.request
from urllib.parse import quote
import json
workbook_id = "abc7cbef-2491-4787-94f8-6542fab12a4e"
inputs = json.dumps({"Sheet1":{"C6":25000}})
outputs = json.dumps({"Sheet1":["C13", "B14:C16"]})
simulate_url = f"https://www.equalto.com/suresheet/api/v1/simulate/{workbook_id}?inputs={quote(inputs)}&outputs={quote(outputs)}"

with urllib.request.urlopen(simulate_url) as response:
    results = json.loads(response.read())

print(json.dumps(results, indent=4))
```

Should print:

```json
{
    "Sheet1": {
        "C13": 50783.31719489607,
        "B14:C16": [
            [
                "   Initial investment amount:",
                25000.0
            ],
            [
                "   Additional contributions:",
                10500.0
            ],
            [
                "   Interest earned:",
                15283.31719489607
            ]
        ]
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://suresheet-docs.equalto.com/python-examples.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
