3번째 Python 동영상은 Python의 Function에 대하여 설명하였다.
영상에 따르면 Function 이란
Function is a collection of instructions and a collection of code.
라고 설명해주는데 이 문장이 핵심이 아닐까 생각한다.
def function1():
print("ahhh")
print("ahhhh 2")
print("this is outside the function")
예시 코드로 Function에 대한 일반적인 설명과 실제 예제를 통해 작동하는 원리에 대하여 알려준다.
# a mapping
# input or an argument
def function2(x) :
return 2*x
a = function2(4)
print(a)
를 코딩하면 8 값을 얻을 수 있다.
더 나아가 x, y의 값으로도 지정가능하며,
def function3(x, y) :
return x + y
e = function3(1, 2)
print(e)
를 코딩하면 3의 값을 얻을 수 있다.
def function4(x) :
print(x)
print("still in this function")
return 3*x
f = function4(4)
print(f)
f = function4(4) 실행시 4, still in this function 이 출력되고, print(f) 시 12 값을 얻을 수 있다.
해당 설명 이후 BMI calculator 를 예제로 하여 Function의 대하여 더 설명하여 준다.
중간에 계속해서 Python에 대하여 공부하려 하였으나, 시간이 부족하여 약간 늦어졌다.
다만, 관심있었던 분야로 조금씩이라도 공부를 해나가야겠다.
'Information > IT' 카테고리의 다른 글
[Review] Python Tutorial #5. Introduction to For Loops (0) | 2019.01.02 |
---|---|
[Review] Python Tutorials #4. Introduction to lists (0) | 2018.12.16 |
[Review] Python Tutorials #2 How to use if else statements. (0) | 2018.10.31 |
[IT소식] Apple Special Event. October 30, 2018. Review (0) | 2018.10.31 |
[Review] Python Tutorial #1_ What are variable. (0) | 2018.10.30 |