python 判断三个数字中的最大值,具体代码如下所示:
#判断三个数中最大值
n1= int(input('please enter the firest number:'))
n2 = int(input('please enter the second number:'))
n3 = int(input('please enter the third number:'))
max_num = 0
if n1 > n2:
max_num = n1
if n1 > n3:
max_num = n1
else:
max_num = n3
else:
max_num = n2
if n2 > n3:
max_num = n2
else:
max_num = n3
print('the max_num is:%d'%max_num)
'''
if n1>n2:
max_num = n1
if max_num > n3:
print('the max_num is n1')
else:
print('the max_num is n3')
else:
max_num = n2
if max_num > n3:
print('the max_num is n2')
else:
print('the max_num is n3')
'