# Python coding mode in Mind+

## Switch to the Python coding mode

If you are familiar with the Petoi coding blocks and Python language, you can change to the **Code** mode in Mind+ as follows:

<figure><img src="/files/kDOa6QNU6XJGxyDruHbK" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/kUYqfTeFxjfa4RGYMc9M" alt=""><figcaption></figcaption></figure>

The **Code** mode is a Python3 development environment. You can write any Python script in it and call all the API interfaces of the PetoiRobot library imported by Mind+.&#x20;

You can find the PetoiRobot library in the following directory. There are all the [definitions of API interfaces](/apis/python-api.md#available-apis) in the **PetoiRobot.py**

* Windows\
  C:\Users\\{username}\AppData\Local\DFScratch\extensions\petoi-robot-thirdex\python\libraries\PetoiRobot.py
* MacOS\
  /Users/{username}/Library/DFScratch/extensions/petoi-robot-thirdex/python/libraries/PetoiRobot.py

Here is a sample code :

```python
# The code starts here
from PetoiRobot import *    # must import the PetoiRobot library

# enter the code below
# auto connect serial ports
autoConnect()

# call the APIs to control the Petoi robot
sendSkillStr('ksit', 0.5)
sendCmdStr('T', 0.5)
loadSkill("skillFileName", 0.2)

# close the serial port
closePort()
```

You can also copy the code in the **Auto Generate** area in the **Blocks** mode and then paste it into the code file in the **Code** mode. Then you can edit and run the code.


---

# 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://docs.petoi.com/block-based-programming/python-coding-mode-in-mind+.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.
