ÇÔ¼ö¿¡¼ Æ©ÇÃÀ» ¸Å°³º¯¼ö ³Ñ°ÜÁÙ¶§ ±âº»ÀûÀÎ »ç¿ë¹ýÀº ´ÙÀ½°ú °°´Ù. import numpy as np
def add(x): a, b = x return a + b val = 5, 100 print(add(val)) print(add((1, 5))) °á°ú) 105 6 ¸Å°³º¯¼ö¸¦ Æ©Çðú Æ©ÇÃÀ» »ç¿ëÇÏÁö ¾ÊÀ»¶§µµ È¥¿ëÇؼ »ç¿ë ÇÒ¼öµµ ÀÖ´Ù. import numpy as np
def sub(a=None, b=None): if isinstance(a, tuple): c, d = a return c - d if a is None or b is None: return 0 return a - b print('sub=', sub((3, 1))) print('sub=', sub(100, 1)) °á°ú) sub= 2 sub= 99 PS) ÇÔ¼ö¿¡¼ -> : ±âÈ£ Àǹ̴ ? -> ±âÈ£´Â ¸®ÅÏ °ª ÁÖ¼®À» ³ªÅ¸³½´Ù. : ±âÈ£´Â ÆĶó¸ÞÅÍ ÁÖ¼®À» ³ªÅ¸³½´Ù. ÁÖ¼®À̹ǷΠ¸®ÅÏ°ª, ÆĶó¸ÞÅÍ¿Í °ªÀÌ ÀÏÄ¡ ÇÏÁö ¾Ê¾Æµµ ½ÇÇà¿¡´Â ¿µÇâÀ» ³¢Ä¡Áö ¾Ê´Â´Ù. import numpy as np
def add(x: tuple) -> int: a, b = x return a + b print(add((8, 3))) °á°ú) 11 |