Just curious, but why does this work?


Lesson 15. abs()

I didn't expect this to work, why does it work?

absolute = abs(42)

print absolute


It works because abs() is a built in function that returns the absolute value of a given number.


Yea but It's supposed to be
absolute = abs(-42)


absolute = abs(42)


Well that is simply because Codecademy's SCT was testing for absolute to be equal to 42.

|42| = 42
|-42| = 42
|42| = |-42|

The SCT got the result it wanted and accepted your code.


SCT? What's that?

And now that makes sense.

EDIT: I needed to thank you :smiley: :grin:


The SCT or Submission Correctness Test is the lesson checker program behind the exercise.

Good, I'm glad you understand.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.