Why do I get a very long decimal output?

link to project: Learn Python 3 | Codecademy
Why do I get 43.199999999999996 as part of the output when the math adds up to 43.2? Thanks.
here’s the code:

weight = 4.8
cost_normal_ground = 0
#ground shipping
if weight <= 2:
  cost_normal_ground = 1.5 * weight
elif weight <= 6:
  cost_normal_ground = 3 * weight
elif weight <= 10:
  cost_normal_ground = 4 * weight
else:
  cost_normal_ground = 4.75 * weight
cost_normal_ground += 20
print("Normal ground shipping cost: $" + str(cost_normal_ground))
#premium ground shipping
cost_premium_ground = 125
print("Premium ground shipping cost: $" + str(cost_premium_ground))

#drone shipping
cost_drone = (cost_normal_ground - 20) * 3
print("Drone shipping cost: $" + str(cost_drone))

output:
Normal ground shipping cost: $34.4
Premium ground shipping cost: $125
Drone shipping cost: $43.199999999999996

Floating point arithmetic. This would be worth Googling if you have some spare time and a technical mind.

>>> 0.1 + 0.2
0.30000000000000004
>>> 

In Python there are multiple number classes, int being just one of them. Integers are stored as literal values in memory, up to the limit of what can be represented in the memory allowed. We can count on a decent representation in most cases within limit.

Floats are not stored the same way. If you research this thoroughly you will discover that. Keep your eyes peeled.

Of course, this may not be an area where we have or even need any expertise, but to recognize the concern. We can address it right in our print statement…

>>> shipping_cost = 43.199999999999996
>>> shipping_method = "Drone"
>>> print (f"{shipping_method} shipping cost: ${shipping_cost:.2f}")
Drone shipping cost: $43.20
>>> shipping_cost = 43.144444444444446
>>> print (f"{shipping_method} shipping cost: ${shipping_cost:.2f}")
Drone shipping cost: $43.14
>>> shipping_cost = 43.155555555555556
>>> print (f"{shipping_method} shipping cost: ${shipping_cost:.2f}")
Drone shipping cost: $43.16
>>> 

This method only looks at the next digit, none of the rest. Up on 5, down on 4. That’s the rounding rule. We can ignore the remaining digits.

.199999999999996

becomes,

.199

which, when we round the last digit gives,

.20