Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 this issue Jul 13, 2024 · 0 comments

Comments

@krishnakumarg1984
Copy link

krishnakumarg1984 commented Jul 13, 2024

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

No tasks being tracked yet.
@krishnakumarg1984 krishnakumarg1984 changed the title Loyaltybonus test grader code in part 1 incorrectly fails due to decimal place/floating point equality comparison 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 Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant