본문 바로가기
Python 배우기

param_args.py

by 노화방지 Anti-aging Hairstyle 2016. 3. 10.
반응형
def foo(x):                 # x is a function parameter
print("x = " + str(x))

foo(5) # pass 5 to foo(). Here 5 is an argument passed to function foo.

def square(x): # Define a function that prints the square of the passed parameter.
print(x ** 2)

square(4)
square(8)
square(15)
square(23)
square(42)

산출물 (Output)

x = 5
16
64
225
529
1764

* Function parameters are defined inside the parentheses (), following the function name.
A parameter acts as a variable name for the passed argument.


반응형

'Python 배우기' 카테고리의 다른 글

class_definition.py  (0) 2016.03.11
default_parameter.py  (0) 2016.03.11
functions.py  (0) 2016.03.10
continue_keyword.py  (0) 2016.03.10
break_keyword.py  (0) 2016.03.10

댓글