Running jupyter twice won't give the same result

Hi, I have some problems。
The same code is run twice to get different results, how to solve the problem?
But running python from an openmc terminal doesn’t have this problem。
I am not clear which result is credible and want to solve this problem。
I would appreciate it if you could help me。
Thanks。

To get the same result, you would need to restart the Jupyter kernel (from the menu, “Kernel > Restart & Run All”).

Thank you very much for your help.
Now the result is the same twice.
But why doesn’t this happen in the running examples in Example Jupyter Notebooks.
Is there something wrong with my code?
I was worried that this would make my results unreliable.
Thank you again

Jupyter notebooks have a useful but also sometimes confusing property.

The execution order of the cells can be performed as the user requests / differently and this can yield different results.

Running code block 1 then 2 then 3 doesn’t necessarily give the same result as running them in reverse order (3, 2, 1). As the variables shared between code blocks might be in memory it might still run but just give different results

The reset and run all removes all the variable values and starts a fresh running all the code blocks in order.

You can prototype in jupyter then export the notebook to a py file if you want to run it from the terminal if that helps

Thank you for your answer. I have solved the problem.