0

In a Jupyter notebook, when using

1 import sympy as sym, numpy as np
2 q = sym.Symbol('q')
3 print(np.power(q,2))
4 np.power(q,2)

the output is

         q**2
[Out 1]: <sup>2</sup>

i.e., the (last) output is displayed with pretty math (as 2 actually, but I could not produce this above due to the code formatting), while the output of print commands is displayed with pure text. This difference is much more noticeable when displaying fractions, square roots, etc.

Is there any way to force the output of a print command to show "pretty", the same as the result of the last line in the cell?

  • This is probably a duplicate, but you are probably looking for [`IPython.display.display`](https://ipython.readthedocs.io/en/stable/api/generated/IPython.display.html#IPython.display.display). – Fengyang Wang Jan 17 '20 at 02:19
  • @FengyangWang - I had tried something along those lines prior to posting, but I did not get to the answer. An answer to my question is actually contained in the link you posted. But there is also more worth posting, which I will do in the other question. – sancho.s ReinstateMonicaCellio Jan 17 '20 at 13:47

0 Answers0