create account

5.12 Maximum of Two Values - Python by kakradetome

View this thread on: hive.blogpeakd.comecency.com
· @kakradetome · (edited)
$13.32
5.12 Maximum of Two Values - Python
https://www.youtube.com/watch?v=iBT2rrSt1wg

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! :)
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 94 others
properties (23)
authorkakradetome
permlink5-12-maximum-of-two-values-python
categoryprogramming
json_metadata{"tags":["programming","coding","python","maximumof-twovalues","tony-gaddis"],"image":["https://img.youtube.com/vi/iBT2rrSt1wg/0.jpg"],"links":["https://www.youtube.com/watch?v=iBT2rrSt1wg"],"app":"steemit/0.1","format":"markdown","users":["chaten"]}
created2017-01-27 11:14:45
last_update2017-01-27 18:32:15
depth0
children4
last_payout2017-02-27 14:53:18
cashout_time1969-12-31 23:59:59
total_payout_value10.183 HBD
curator_payout_value3.135 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length463
author_reputation31,794,084,266,065
root_title"5.12 Maximum of Two Values - Python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,356,355
net_rshares44,298,536,054,250
author_curate_reward""
vote details (158)
@chaten · (edited)
2 points:
* Your program shadows an inbuilt function, you redefine `max`, which is defined by Python itself, this is a *very* bad thing to do, and should not be in the tutorial.
* This can be done in one line with said inbuilt function, [max](https://docs.python.org/3/library/functions.html#max)
`max(1,12)` will return `12` in the Python console, so you could just have 
`max(FirstNumber, SecondNumber)`

Things to take away from this:
* Do not shadow or any decent programmer will cry their guts out.
* Keep It Simple Stupid (KISS), and use inbuilt functions.
👍  
properties (23)
authorchaten
permlinkre-kakradetome-5-12-maximum-of-two-values-python-20170127t173713421z
categoryprogramming
json_metadata{"tags":["programming"],"links":["https://docs.python.org/3/library/functions.html#max"],"app":"steemit/0.1"}
created2017-01-27 17:37:15
last_update2017-01-27 17:39:00
depth1
children3
last_payout2017-02-27 14:53:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length562
author_reputation1,986,564,144,965
root_title"5.12 Maximum of Two Values - Python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,358,958
net_rshares10,872,040,921
author_curate_reward""
vote details (1)
@kakradetome · (edited)
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 :)
properties (22)
authorkakradetome
permlinkre-chaten-re-kakradetome-5-12-maximum-of-two-values-python-20170127t182319605z
categoryprogramming
json_metadata{"tags":["programming"],"users":["chaten"],"app":"steemit/0.1"}
created2017-01-27 18:23:21
last_update2017-01-27 22:43:51
depth2
children2
last_payout2017-02-27 14:53:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,270
author_reputation31,794,084,266,065
root_title"5.12 Maximum of Two Values - Python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,359,241
net_rshares0
@chaten ·
:D
👍  
properties (23)
authorchaten
permlinkre-kakradetome-re-chaten-re-kakradetome-5-12-maximum-of-two-values-python-20170127t215643265z
categoryprogramming
json_metadata{"tags":["programming"],"app":"steemit/0.1"}
created2017-01-27 21:56:45
last_update2017-01-27 21:56:45
depth3
children1
last_payout2017-02-27 14:53:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2
author_reputation1,986,564,144,965
root_title"5.12 Maximum of Two Values - Python"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id2,360,550
net_rshares10,872,186,885
author_curate_reward""
vote details (1)