rage / programming-24

63 stars 39 forks source link

Loyaltybonus test grader code in part 1 incorrectly fails due to not correctly handling decimal place/floating point equality comparison differences in the answer string from other valid approaches #53

Open krishnakumarg1984 opened 4 months ago

krishnakumarg1984 commented 4 months ago

Prima facie, it appears that the Loyaltybonus test grader (in this page of part 1) is doing an exact string check which does not correctly handle the discrepancies arising due to floating point differences in answers from equally valid alternative approaches. This results in errors such as the following:

FAIL: LoyaltyBonusTest: test_under_100_random

With input 88 correct amount of points 96.80000000000001 is not found in output Your bonus is 10 %
You now have 96.8 points

whilst attempting to grade the following correctly implemented solution:

points = int(input("How many points are on your card? "))
if points < 100:
    bonus_points = 0.1*points
    print("Your bonus is 10 %")

if points >= 100:
    bonus_points = 0.15*points
    print("Your bonus is 15 %")

points += bonus_points
print("You now have", points, "points")

P.S: Please let me know if you'd like me to redact my code solution (or please feel free to do so yourself).

### Tasks