Jan-27-2020, 05:51 AM
(This post was last modified: Jan-27-2020, 06:37 AM by michael1789.)
To be sure you know the absolute value of
And the absolute value of 0 is None. It has no value. You can add as many as you want and still 0. Not a math person exactly, but I think absolute value is the measurement of a number from 0 in integers. 5 and -5 are both absolute 5 as they are both 5 whole numbers from 0.
Oh, I missed this. You'll note that your second print line is actually the output for the first entry. You are calling
This works:
n
can be found with abs(n)
.And the absolute value of 0 is None. It has no value. You can add as many as you want and still 0. Not a math person exactly, but I think absolute value is the measurement of a number from 0 in integers. 5 and -5 are both absolute 5 as they are both 5 whole numbers from 0.
(Jan-27-2020, 05:51 AM)michael1789 Wrote: the print line appeared twice -- and I have no idea how the second print line
Oh, I missed this. You'll note that your second print line is actually the output for the first entry. You are calling
main()
from with another function, it runs that execution of main()
then finishes the first one it started when it drops back out.This works:
while True: def absoluteValue(n): if n < 0: return -n elif n > 0: return else: print("Please key in a value greater or lower than 0 !! ") def main(): y = input("Key in an integer : ") n = int(y) print("The Absolute Value of", y, " is ", absoluteValue(n)) main()