728x90
'''
functoin func(,){
}
'''
def func():
print('func()호출')
func()
'''
func()호출
'''
def funcRange(val, n):
for i in range(n):
print(val)
funcRange("안녕", 3)
'''
안녕
안녕
안녕
'''
#가변인수(인자) func()
def funcRange1(n, *values):
for i in range(n):
for v in values:
print(v)
print()
funcRange1(3,"안녕","하이","파이썬")
#default 인수
def funcRange2(value, n=3):
for i in range(n):
print(value)
funcRange2("안녕하세요") #default인수가 있기때문에 자동으로 3들어감
print()
funcRange2("안녕하세요", 5 ) #default인수 재설정
print()
funcRange2("안녕하세요", n=10 )
def testFunc (a,b=10,c=100):
print(a+b+c)
testFunc(10) #120
testFunc(a=1,b=2,c=3) #6
def testFunc1():
print('testFunc1() 호출')
return True
print(testFunc1())
#return 값을 다수
def testReturn():
return (10,20)
a,b = testReturn()
print(a,b)
#함수를 여러번 호출이 가능
def myfunc():
print('func()호출')
def call10Func(_func):
for i in range(10):
_func()
call10Func(myfunc)
#modul -library(dll)
'''
import calculator
result = calculator.add(10,3)
print(result)
'''
from calculator import div
d = div(3,2)
print(d)
728x90
'python' 카테고리의 다른 글
파이썬 알고리즘 강의/파이썬 기초 문법 1_변수와 출력함수 (0) | 2021.09.18 |
---|---|
Seaborn 시각화 연습_Heatmap,Pairplot,jointplot,tsplot (0) | 2021.05.14 |
82일차//python/ 가위바위보 프로그램/ 파이썬 (0) | 2021.05.04 |
82일차//python/import math + random (0) | 2021.05.04 |
81일차//python/dictionary (0) | 2021.05.03 |