Hi there I am new to this.
Code:
display(Math('4^4.2'))
Output:
enter image description here
What am I doing wrong. The decimal is not up on the exponents
I have tried to keep the exponents nicely formatted including the decimals but the decimals came down.
samcarter_is_at_topanswers.xyz
40.4k5 gold badges64 silver badges85 bronze badges
2 Answers 2
there are a few ways of achieving a power (exponent) in python.
here are the two most common ways.
- use the
**and not^. - use the
pow()function
result = 4**4.2
print(result)
result = pow(4, 4.2)
print(result)
answered Nov 19, 2023 at 13:21
darren
6,1118 gold badges43 silver badges78 bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
Stef
I think they're using MathJax or some variant, so they're not looking for actual arithmetic exponent, but just for pretty displaying of equations. Their question is not really related to python at all.
darren
@Stef, you could be right. i am answering on the basis that
python is a tag and i see a jupyter notebook in the image provided. If it is mathjax, then it is a different language JavaScript ...LaTeX doesn't automatically add parentheses like python does. How does it know that (2^2).4 isn't a new notation? Generally you should put braces around the exponent and other things:
2^{2.4}
1 Comment
DonCarleone
Please offer a better way to write this statement.
lang-py
'4^{4.2}'.