# κ°λ³ μΈμλ₯Ό μ¬μ©νλ ν¨μ => μΈμμ κ°μκ° κ°λ³μ μΈ ν¨μ => κ°λ³ μΈμλ '*λ³μμ΄λ¦' ννλ‘ μ μΈνλ€.
=> κ°λ³ μΈμλ λμ΄μ€λ λ°μ΄ν°λ₯Ό ννλ‘ λ°μμ μ²λ¦¬νλ€.
# κ°λ³ μΈμλ μΈμ λͺ©λ‘μ 맨 λ§μ§λ§μ λ± 1λ²λ§ μ¬μ©ν μ μλ€.
def func6(*args):
# print(type(args))
# print(args)
total = 0
for i in args:
total += i
return total
def func6(*args):
# print(type(args))
# print(args)
total = 0
for i in args:
total += i
return total
print(func6(1)) # μΈμμ κ°μ 1κ°, total: 1
print(func6(1, 2)) # μΈμμ κ°μ 2κ°, total: 3
print(func6(1, 2, 3)) # μΈμμ κ°μ 3κ°, total: 6
print(func6(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) # μΈμμ κ°μ 10κ°, total: 55
print(func6(1)) # μΈμμ κ°μ 1κ°, total: 1
print(func6(1, 2)) # μΈμμ κ°μ 2κ°, total: 3
print(func6(1, 2, 3)) # μΈμμ κ°μ 3κ°, total: 6
print(func6(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) # μΈμμ κ°μ 10κ°, total: 55
λ.
728x90
':: Python π© > κΈ°μ΄' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[Python] 19. λ¬λ ₯λ§λ€κΈ° -2- (0) | 2021.03.08 |
---|---|
[Python] 18. λ¬λ ₯λ§λ€κΈ° -1- (0) | 2021.03.07 |
[Python] 15_function_3 , 16_function_4 [ν¨μ νΈμΆ, λν΄νΈ μΈμ] (0) | 2021.03.07 |
[Python] 14_function_2 [μ€λ²λ‘λ© μ§μx] (0) | 2021.03.03 |
[Python] 13_function_1 [def ν¨μ] (0) | 2021.03.03 |
λκΈ