mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 15:01:08 +00:00
df04d94543
* Renaming directories * Adding a recursive factorial algorithm
19 lines
273 B
Python
19 lines
273 B
Python
def absVal(num):
|
|
"""
|
|
Function to fins absolute value of numbers.
|
|
>>absVal(-5)
|
|
5
|
|
>>absVal(0)
|
|
0
|
|
"""
|
|
if num < 0:
|
|
return -num
|
|
else:
|
|
return num
|
|
|
|
def main():
|
|
print(absVal(-34)) # = 34
|
|
|
|
if __name__ == '__main__':
|
|
main()
|