How one can use Python to do computations on calc?

Can one use Python scripts in Libreoffice macros? I have Libreoffice calc 6.0.7.3 and Ubuntu 18.04. I installed libreoffice-script-provider-python. But how can I make some basic computation that tests if everything works? For example, if cell A1 contains value 1 and A2 contains value 2, then how can I compute (A1+A2)**4 via Python and put the value to the cell A3?

Try:

doc = XSCRIPTCONTEXT.getDocument()
sheet = doc.Sheets[0]

c1 = sheet['A1']
c2 = sheet['A2']
c3 = sheet['A3']

#If you wan calculate and set only value
c3.Value = (c1.Value + c2.Value) * 4

#If you want set formula
c3.Formula = '=(A1+A2)*4'

Thanks. I mean that where should I put that script such that I can control when to run it?

Look: Python Guide - Introduction - The Document Foundation Wiki
and: https://wiki.documentfoundation.org/Macros/Python_Guide/My_first_macro