파이썬 키워드 매개변수
-
52 - (파이썬) 기본 매개변수study with Q - 파이썬 2024. 6. 10. 20:54
#기본 매개변수def test (v = 10): print(v)test()test(30)test(v = "str")>>>1030str #키워드 매개변수 / 기본 매개변수: 기본 매개변수가 2개 이상일 때를 생각해보면 def test (v = 10, i = 15): print(v,i)test()test(10, 50)>>> 10 1510 50...이럴거면 변수 v를 지정해둔 의미가 없잖여그래서 변수를 바꾸고자 하는 키워드만 바꿔서 입력 def test (v = 10, i = 15): print(v,i)test()test(i = 50)>>>10 1510 50 ※ 기본 매개변수는 마지막에 입력해야 한다.: 기본 매개변수를 먼저 입력해야 하는 상황이 오기 때문에def test (v = 10, i): pr..