Floating-point equality in loop
Review this Python loop that steps through a range by 0.1 and checks for a target.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.
0:00 of about 25 min
Mark a line and say what kind of problem it is.0 findings
1def hit_target(start, stop, step, target):
2 x = start
3 while x <= stop:
4 if x == target:
5 return True
6 x += step
7 return False
8
9# hit_target(0.0, 1.0, 0.1, 0.3)
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.