+ 1

I don't understand this code...

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

31st Aug 2019, 9:59 AM
Suraj Das
Suraj Das - avatar
2 Respuestas
+ 2
First example : max(4, 7) x -> 4 y -> 7 x >= y ? No : return y #7 Second example : max(8, 5) x -> 8 y -> 5 x >= y ? Yes : return x #8
31st Aug 2019, 10:06 AM
Théophile
Théophile - avatar
+ 5
in that code the function max gets declared. in short it returns the bigger of the two arguments that are passed in. for the arguments 4, 7 the function returns 7 since 7 is bigger than 4 for the arguments 8, 5 the function returns 8 since 8 is bigger than 5
31st Aug 2019, 10:03 AM
Anton Böhler
Anton Böhler - avatar