> For the complete documentation index, see [llms.txt](https://zapit.gitbook.io/user-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zapit.gitbook.io/user-guide/running-experiments/python/basic-zapit-api-use-in-python.md).

# Basic Zapit API Use in Python

Make sure you are first familiar with [Basic API Usage in MATLAB](/user-guide/running-experiments/matlab/basic-api-usage-in-matlab.md).

The following code presents 10 random trials using Zapit's Python bridge.

```python
import zapit_python_bridge.bridge as zpb
from time import sleep

# Create an instance of the bridge object
hZP = zpb.bridge()
num_cond = hZP.num_stim_cond()

numTrials = 10
currentTrial = 1

while currentTrial <= numTrials:
    # Send stimuli and do not log because this an example.
    # In a real experiment you likely want to enable both logging
    # and hardware triggering.
    print("Presenting stimulus %d/%d" % (currentTrial, numTrials))
    hZP.send_samples(conditionNum=-1, hardwareTriggered=False, logging=False)

    sleep(1)

    hZP.stop_opto_stim()
    currentTrial += 1

hZP.release_matlab()

```
