When realising the following operation:

do = 1.0 - 2.718281828**(-(23**2)/730)
print do

Python returns 0.632120558766

When you do it on the calculator or when google it, it returns 0.515509538


6 Years
Discussion Span
Last Post by vegaseat

"/ 730" has to be a float (or you have to convert somehow).

##1.0 - 2.718281828**(-(23**2)/730)
a = 23**2
print a
a *= -1
print a
print "---------------"
print a/730
a /= 730.0
print a
print "---------------"
b =  2.718281828**a
print b
print 1.0 - b

Edited by woooee: n/a


Something like
q = 3/5
would signify a division of integers and would give you
q = 0
in most computer languages and Python2

Python3 has changed this '/' is now a floating point division and '//' is an integer division.

If you want q to be a floating point in Python2, then you simply use
q = 3/5.0

print (23**2)/730     # 0
print (23**2)/730.0   # 0.724657534247

Edited by vegaseat: n/a


The compiler will take your math expression and turn it into a series of smaller stepwise expressions. That one time .0 can easily get lost. Anyway, Python3 takes care of that ambiguity.

Edited by vegaseat: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.