Floating point calculation problem
schiz_man at 21stcentury.com
Sat Feb 2 11:27:07 CET 2013
I have a program that performs some calculations that runs perfectly on
Python 2.7.3. However, when I try to execute it on Python 3.3.0 I get the
numer = math.log(s)
TypeError: a float is required
The quantity s is input with the following line: s = input("Enter s: ")
To get rid of the compile error, I can cast this as a float: s =
float(input("Enter s: "))
However, then the result returned by the method is wrong. Why does this
error occur in version 3.3.0 but not in 2.7.3? Why is the result incorrect
when s is cast as a float (the casting is not required in 2.7.3)? How is
Python dynamically typed if I need to cast (in version 3.3.0 at least) to
get rid of the compile error?
Thanks in advance.
PS - I'm a Python newbie.
More information about the Python-list