1#Returns the number with the highest value.
2#If the values are strings, an alphabetical comparison is done.
3x = max(-5, 12, 27)
4print(x)#Prints 27 to the console.
1# This program will find out the greater number in the arguments
2
3def larger_number(x, y):
4 if x > y:
5 print(x, "is greater")
6 else:
7 print(y, 'is greater')
8
9larger_number(12, 31)
10
1def highest_even(li):
2 evens = []
3 for item in li:
4 if item % 2 == 0:
5 evens.append(item)
6 return max(evens)
7
8print(highest_even([10,2,3,4,8,11]))
9
10
11# Building a function to find the highest even number in a list
12
1def max_num_in_list( list ):
2 max = list[ 0 ]
3 for a in list:
4 if a > max:
5 max = a
6 return max
7print(max_num_in_list([1, 2, -8, 0]))
8
9