I am trying to write a program whereby the user can enter two values, and the program will calculate the absolute error between the values.
A sample input would be:
87.03
87
With the approximate value read in first and the correct value second. The output should be:
The absolute error is: 0.03
Here is my attempt that is refusing to work!
a=raw_input("What is the approximate value?")
b=raw_input("What is the correct value?")
print "The absolute error is: %s" %abs(a-b)
The error I'm getting is:
TypeError
Traceback (most recent call last)
<ipython-input-1-9320453c4e23> in <module>()
1 a=raw_input("What is the approximate value?")
2 b=raw_input("What is the correct value?")
----> 3 print "The absolute error is: %s" %abs(a-b)
TypeError: unsupported operand type(s) for -: 'str' and 'str'
And I really do not have any idea what it means. Any help would be greatly appreciated.