How use Python program in calc

I’d like to be able to use a Python program to provide values for a variable in calc?

Can this be done?

In this thread from Oweng LO Programming Documentation - LibreOfficeForum, I think you can find some help.