Issue
I built a calculator for a bio equation, and I think I've narrowed down the source of my problem, which is a natural log I take:
goldman = ((R * T) / F) * cmath.log(float(top_row) / float(bot_row))
print("Membrane potential: " + str(goldman) + "V"
My problem is that it will only display the output in a complex form:
Membrane potential: (0.005100608207126714+0j)V
Is there any way of getting this to print as a floating number? Nothing I've tried has worked.
Solution
Complex numbers have a real part and an imaginary part:
>>> c = complex(1, 0)
>>> c
(1+0j)
>>> c.real
1.0
It looks like you just want the real part... so:
print("Membrane potential: " + str(goldman.real) + "V"
Answered By - mgilson
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.