def self_max(x,y):
if x>y:
return x,1
else:
return y,2
print( self_max(53453,32423))
#####################
def self_max(x,y,a,b,c,d=10):
if x>y:
return x,a
else:
return y,d
self_max(23,6,3,5,'f')
########################
可变长实参
def self_max(a,b,c,d,e,f,g,h,j,l,o=0,ss=9):
print(a,b,c,d,e,f,g,h,j,l,o,ss)
args=[1,2,3,4,5,6,7,8,9,9,9]
kwargs={'ss':444}
self_max(*args,**kwargs)
可变长形参
def self_max(args,**kwargs):
print(args) #a接受所有位置实参,元组形式保存
print(kwargs) #b接受所有关键字实参,字典形式保存
self_max(1,2,3,4,5,6,x=7,y=9)
##########################
def trans():
print('from trans')
def withdraw():
print('from withdraw')
func_dicr={0:trans,
1:withdraw,
}
func_print={0:'trans',
1:'withdraw',
2:'quit'}
while True:
print(func_print)
choice = input('请选择功能>>>').strip()
choice_int=int(choice)
if choice_int==2:
break
func_dicr[choice_int]()
#####################################
#####################################
def f1():
def f2():
print('from f1')
f2()
f1()
######################################
from cmath import pi
def circle(action,r):
if action == 'p':
def circle_p():
return 2pir
re=circle_p()
elif action == 'a':
def circle_a():
return pi*r**2
re=circle_a()
else:
re = '请正确输入!'
return re
r_choice = int(input('请输入半径>>>'))
action_choice = input('请选择功能>>>a:面积,p:周长')
re =circle(action=action_choice,r=r_choice)
print(re)
######################################