def add(a, b): return a + b print(add(1, 2))
def greet(name, message): print(f"{name}, {message}") greet(name="Tom", message="Hello!")
def find_min_max(l): return min(l), max(l) my_list = [1, 2, 3, 4, 5] my_min, my_max = find_min_max(my_list) print(f"The minimum value is {my_min} and the maximum value is {my_max}.")
def greet(name="User"): print(f"Hello, {name}!") greet() # 输出结果为 "Hello, User!" greet("Tom") # 输出结果为 "Hello, Tom!"
def greet(*names): for name in names: print(f"Hello, {name}!") greet("Tom", "John", "Henry")
def greet(**names): for name in names: print(f"Hello, {names[name]}!") greet(Tom="Mr. Tom", John="Dr. John", Henry="Mr. Henry")
标签: 站长工具