(python) Abs function re-create question

Asked 2 months ago, Updated 2 months ago, 358 views

I'm studying how to make a Python function algorithm again. 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 08:22

1 Answers


2022-11-09 09:24

If you have any answers or tips


© 2023 OneMinuteCode. All rights reserved.