Variable replacement in py file

I’m not quite following what you are asking either, but this part sounds to me like you may want to run the script in the namespace of the active notebook, and so instead of using import you may want to use the IPython/Jupyter magic %run command and combine it with the interactive flag -i so that the code is run in the namespace. It is at least an option.

It would be something like this:

%run -i aa.py
say_hello()

After you edit say_hello to use f-strings like Paul suggests.
See more about the interactive flag for the IPython/Jupyter magic %run command here and here.