Hello Everyone! Ultimately, we would use the predefined function max() to solve a question like this, but we recreated the wheel here to see a variation of the max() function! :) Thanks to @chaten for hinting at this :)
Starting out with Python, Third Edition, Tony Gaddis
Chapter 5
Programming Challenges
12 ) Maximum of Two Values
Starting out with Python. Third Edition. Tony gaddis.
Happy Steeming Everyone! :)
2 points:
max
, which is defined by Python itself, this is a very bad thing to do, and should not be in the tutorial.max(1,12)
will return12
in the Python console, so you could just havemax(FirstNumber, SecondNumber)
Things to take away from this:
Very well said! Thank you :) As you may have seen from the description, this is a question from a book, Starting out with Python that only allows you to include knowledge and concept from a particular chapter. The author certainly knows there's a predefined max function. But as a "programming challenge" and a learning process, the author was explicit and wanted us to first create the max function or at least a variation of it, to see how it works first and to see the inner working of it instead of just relying on it. This was a test, so students can appreciate predefined functions even better by first understanding the concept of creating functions.
I understand programmers wouldn't normally do that and I 100% agree :) If I was creating a program for production, I would use the predefined max() but again this was only to recreate the wheel, not for a bad purpose but for learning purposes. You're right! I should at least point out in the description, there's a predefined function max() ( Done! :) see description ), for those who don't know, but the students using the book definitely would know about it if they read the book.
Thank you so much @chaten for your contribution. Viewers will definitely learn from your comment. Please keep them coming :)
:D
:D