(python)abs Function Recreate Question

Asked 1 years ago, Updated 1 years ago, 272 views

I'm studying how to rebuild the Python function algorithm. It's really not easy. Below is the coding that I redefined the ABS function.

def my_abs(number):
    if number < 0:   
    number * -1
    elif number > 0:
    number * 1

test1 = 1.7
test2 = -8

a=my_abs(test1)
b=my_abs(test2)

print(a,b)

What's the problem?

Please give me a map~

python

2022-11-09 05:43

1 Answers


2022-11-09 06:05

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.