0
Mathematic operation
Charity1Total =0 bill = float(input("enter customer bill")) Donation =0.01 *bill print(" The total for Charity is: " + str(Charity1Toal)) 1)the problem being the result of Charity1Total is incorrect. For example an input of 12.12 results to 0.1211999999...
2 Respostas
+ 1
Don't know how it must work, but this one works fine:
Charity1Total = 0.0
bill = float(input("Enter customer bill: "))
Donation = bill - 0.01
print("The total for Charity is: " + str(Charity1Total + Donation))
You can change it to your own solution.
0
I think you are missing a line there which may help explain your problem a little better. so far if I assume the missing line where you put the donation in to the charity is
Charity1Total += Donation? would be odd because it I think it should = 0.
however, the main issue here might be converting between int and float.
Python makes assumptions about the type when you initialise it. so x = 0 will be an int but x =0.0 will be a float. since you are dealing with floats try Donation1Total = 0.0. let me know how it goes. sorry not near a computer to try it for you
also out of interest just try and print the values after you assigned them. I.e
print(bill)
print(Donation)
print(Charity1Total). might help you solve where there value is getting mangled