- Code: Select all
Difference = 0
A = float(input ('Input Number 1 :- '))
B = float(input ('Input Number 2 :- '))
Difference = A-B
print ('Difference is',Difference)
Difference = 0
A = float(input ('Input Number 1 :- '))
B = float(input ('Input Number 2 :- '))
Difference = A-B
print ('Difference is',Difference)
a = float(input("Enter first number: "))
b = float(input("Enter second number: "))
difference = a-b
print ("Difference is: {:.2f}".format(difference))
>>>
Enter first number: 25.25
Enter second number: 45.55
Difference is: -20.30
>>>
Mekire wrote:The problem is that base 2 can't represent base 10 fractions particularly well.
Read this:
http://docs.python.org/2/tutorial/floatingpoint.html
-Mek
Edit:
This is probably what you want:
- Code: Select all
a = float(input("Enter first number: "))
b = float(input("Enter second number: "))
difference = a-b
print ("Difference is: {:.2f}".format(difference))
- Code: Select all
>>>
Enter first number: 25.25
Enter second number: 45.55
Difference is: -20.30
>>>
Users browsing this forum: No registered users and 1 guest