uaveiro-leci/1ano/1semestre/fp/aula03/ex05_06.py

27 lines
487 B
Python
Raw Normal View History

2022-10-11 19:27:51 +00:00
def max2(x, y):
if x > y:
return x
else:
return y
2022-10-11 19:27:51 +00:00
def max3(x, y, z):
return max2(x, max2(y, z))
2022-10-18 17:18:56 +00:00
def main():
n1 = float(input('Introduza dois valores.\nN1: '))
n2 = float(input('N2: '))
2022-10-11 19:27:51 +00:00
2022-10-18 17:18:56 +00:00
print('\nO maior valor é: ', max2(n1, n2))
2022-10-11 19:27:51 +00:00
2022-10-18 17:18:56 +00:00
n1 = float(input('\n\nIntroduza tres valores.\nN1: '))
n2 = float(input('N2: '))
n3 = float(input('N3: '))
2022-10-11 19:27:51 +00:00
2022-10-18 17:18:56 +00:00
print('\nO maior valor é: ', max3(n1, n2, n3))
if __name__ == "__main__":
main()