Write a function that takes in 4 integers and returns the largest.
def brREMOVEDselSprouts(a, b, c, d):
foo = max(a, b)
foo = max(foo, c)
foo = max(foo, d)
return foo
Another instance of did-you-know. There's a function called
max that takes in two numbers and returns the larger of the two. So with that in mind, let's trace this...
- First we define the function brREMOVEDselSprouts so that it takes in 4 values.
- Then we take the first two values, and see which one is bigger. The winner of that comparison is stored into the variable foo.
- Now we take the winner from the previoREMOVED line and compare it to the 3rd number.
- Now we take the winner from the previoREMOVED line and compare it to the 4th number.
- We are now guaranteed that whatever value is stored in the variable foo is the largest of the 4. So now we return it.