0

Please help!! code not understood...its dark here.

def max(x, y): if x >=y: return x else: return y print(max(4, 7)) z = max(8, 5) print(z)

15th May 2018, 7:52 PM
Tshepiso Mokoena
Tshepiso  Mokoena - avatar
1 Odpowiedź
+ 3
it's really not hard if you analyse it. You created a function max, which returns the bigger one of two numbers. Let me break it down, 'def max(x, y)' this creates function max, ' if x >=y: return x else: return y' This checks for the bigger number between the two numbers given. 'print(max(4, 7))' This calls the function max, and prints out the bigger number i.e '7' 'z = max(8, 5)' This checks for the bigger number between 8 and 5 and assigns the number to z 'print(z)' This prints out the number assigned to z
15th May 2018, 10:06 PM
ghali lawal
ghali lawal - avatar