• Register

Kako se v f-stringu zapiše n-ti, npr. tretji koren števila?

+4 votes
57 views
asked Dec 16, 2018 by tadejbizjak (1,070 points)

1 Answer

+2 votes
 
Best answer

V običajnem izpisu teksta mislim, da to ni mogoče. V Jupyter Notebook-u lahko uporabite IPython.display in Math za LaTeX izpis. Primer:

from IPython.display import Math, display
import numpy as np

n_koren = 7
a = 2555.55

izpis = f'$ \\sqrt[ {n_koren} ]{{ {a:.0f} }} = {a**(1/n_koren):.10f} $'
display(Math(izpis))

answered Dec 17, 2018 by dgorjup (60,090 points)
selected Dec 17, 2018 by janko.slavic
...