Skip to main content
Skip table of contents

함수 문법

기능

  • 선언: def로 시작하고 콜론(:)으로 끝냅니다.

  • 함수의 시작과 끝은 코드의 들여쓰기로 구분합니다.

  • interface/implementation을 따로 구분하지 않습니다. , 사용 전에 미리 정의되어야 합니다.

  • 함수명을 예약어나 DRL 명령어 이름과 동일하게 사용하면 인터프리터에 치명적인 에러가 발생합니다
    이를 피하기 위해서 가급적 “fn_” 이란 prefix를 사용하여 함수 이름을 사용하시기 바랍니다


주의

하기 예약어들을 변수명이나 함수명으로 절대로 사용하지 마십시요.

and

assert

break

class

continue

def

del

elif

else

except

exec

finally

for

from

global

if

import

in

is

lambda

list

not

open

or

pass

print

raise

return

try

while

with

yield

select

 

 

문법

def <함수명>(인수1, 인수2, … 인수N):
<구문> …
return <반환값>

PY
#예)
def fn_Times(a, b):
return a * b

fn_Times (10, 10)

def fn_Times(a, b):
return a * b

tp_log(str(fn_Times(10, 5)))
#expected result: 50

def movej(): #movej는 DRL 명렁어로 함수명으로 사용하면 안 됩니다.
return 0

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.