I have this Replit for an IGCSE computer science assignment.
I'm supposed to calculate change by subtracting price from cash given.
Here's my code:
Everything works well when I subtract two whole numbers, but when I subtract, for example 7.48 from 10, I get 2.5199999999999996 which is wrong.
I'm supposed to calculate change by subtracting price from cash given.
Here's my code:
Python:
price = float(input("Price in Pounds and pence: £"))
cash_given = float(input("Cash given: £"))
change = cash_given - price
print("\nChange: £" + str(change))