📜  python代码示例中具有参数默认值的函数

📅  最后修改于: 2022-03-11 14:45:16.365000             🧑  作者: Mango

代码示例1
def fan_speed(speed = 1 )-> str:
    if speed > 5:
        return "fan can't go with more speed "
    return "The speed of fan is " + str(speed)
print(fan_speed(6))
print(fan_speed(4))
print(fan_speed())#if you don't provide the speed of fan the fan will come 
#to its defalt value 1 and the speed of fan will become 1