# Code could be faulty under different cirumstances?

Hello everyone
I’ve been going over high order functions and in one of the pages there was a coding exercise to basically take a list of grades, some in the four point scale and some in the 100 point scale and turn them all to the 100 point scale.

I thought of this:

``````grade_list = [3.5, 3.7, 2.6, 95, 87]

# assign the result of your map function to the variable grades_100scale
``````

``````grade_list = [3.5, 3.7, 2.6, 95, 87]

# assign the result of your map function to the variable grades_100scale
``````

Maybe I just don’t know enough about the four point scale but what if someone for example got a 4?
Is the four point scale always a float or can it be an int? and if can be an int is my fault can be considered faulty?

One of the schools I know had its 4 point scale set up something like this:
60% <=> 0.0
70% <=> 1.0
80% <=> 2.0
90% <=> 3.0
100% <=> 4.0

So the formula to convert % grades to the 4 point scale would be something like:
`grade_4scale = (grade_100scale / 10 ) - 6 if (grade_100scale > 60) else 0.0`

And the formula to convert grades on the 4 point scale to % grades would be something like:
`grade_100scale = (grade_4scale * 10) + 60`

spoiler:

If those were mixed, the lambda function I’d use would be

``````lambda grade: (grade * 10) + 60 if grade > 4.0 else grade
``````

The answer could be a `float`, I guess;
but you can convert it to an `int` if you want.

1 Like

No, I believe that particular grading method (which you’ll find predominantly in North America, though I’m sure there’s other places which use it) would still refer to the “top mark” as “four point oh” (4.0) and not just “four” so the grade ought to always be a float.

That being said, I’m not sure that I entirely agree with the “solution” implementation… because, whilst you would hope it would be unlikely, it is possible to score below 4 on a percentage grading system… Doesn’t look like that particular edge case would be correctly handled.

GPA equates with z-score, does it not? The Standard Normal Curve is skewed out of the negative such that z=2 is the Normal. Mind this could be bollocks. Just reaching for some math that has a scale of 4.

1 Like

That > should be ≤

``````lambda grade: (grade * 10) + 60 if grade <= 4.0 else grade
``````

but it does not deal with edge cases.