Created
May 15, 2020 03:25
-
-
Save epireve/8cc2dfab5f5bd3e46773ff5f253ab14c to your computer and use it in GitHub Desktop.
A function called max_num() that has three parameters named num1, num2, and num3. The function should return the largest of these three numbers. If any of two numbers tie as the largest, you should return "It's a tie!".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Write your max_num function here: | |
def max_num(num1, num2, num3): | |
# if (num1>num2) and (num1>num3) return num1 | |
# if (num1>num2) and (num1>num3) return num1 | |
list = [num1, num2, num3] | |
list.sort() | |
# print(list[0]) | |
# print(list[1]) | |
# print(list[2]) | |
first = list[-1] | |
second = list[-2] | |
if first>second: return first | |
elif first==second: return "It's a tie!" | |
# Uncomment these function calls to test your max_num function: | |
print(max_num(-10, 0, 10)) | |
# should print 10 | |
print(max_num(-10, 5, -30)) | |
# should print 5 | |
print(max_num(-5, -10, -10)) | |
# should print -5 | |
print(max_num(2, 3, 3)) | |
# should print "It's a tie!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment