[Algorithm] μ λκ°
μ λκ° κ΅¬νκΈ° μκ³ λ¦¬μ¦
ifλ¬Έμ μ΄μ©ν μ λκ° κ΅¬νκΈ°
def abs_sign(a):
if a >= 0:
return a
else:
return -a
print(abs_sign(5))
print(abs_sign(-3))
μ κ³±κ·Όμ μ΄μ©ν μ λκ° κ΅¬νκΈ°
import math # μν λͺ¨λ μ¬μ©
def abs_square(a):
b = a * a
return math.sqrt(b) # μν λͺ¨λμ μ κ³±κ·Ό ν¨μ
print(abs_square(5))
print(abs_square(-3))