Python/maths/abs.py
PatOnTheBack bd4017928e Added Whitespace and Docstring (#924)
* Added Whitespace and Docstring

I modified the file to make Pylint happier and make the code more readable.

* Beautified Code and Added Docstring

I modified the file to make Pylint happier and make the code more readable.

* Added DOCSTRINGS, Wikipedia link, and whitespace

I added DOCSTRINGS and whitespace to make the code more readable and understandable.

* Improved Formatting

* Wrapped comments
* Fixed spelling error for `movement` variable
* Added DOCSTRINGs

* Improved Formatting

* Corrected whitespace to improve readability.
* Added docstrings.
* Made comments fit inside an 80 column layout.
2019-07-01 16:10:18 +08:00

26 lines
333 B
Python

"""Absolute Value."""
def absVal(num):
"""
Find the absolute value of a number.
>>absVal(-5)
5
>>absVal(0)
0
"""
if num < 0:
return -num
else:
return num
def main():
"""Print absolute value of -34."""
print(absVal(-34)) # = 34
if __name__ == '__main__':
main()