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! :)
author | kakradetome |
---|---|
permlink | 5-12-maximum-of-two-values-python |
category | programming |
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"]} |
created | 2017-01-27 11:14:45 |
last_update | 2017-01-27 18:32:15 |
depth | 0 |
children | 4 |
last_payout | 2017-02-27 14:53:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 10.183 HBD |
curator_payout_value | 3.135 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 463 |
author_reputation | 31,794,084,266,065 |
root_title | "5.12 Maximum of Two Values - Python" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 2,356,355 |
net_rshares | 44,298,536,054,250 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
berniesanders | 0 | 7,983,772,535,734 | 57% | ||
penambang | 0 | 5,436,859,450 | 18% | ||
berkah | 0 | 45,350,232,751 | 60% | ||
proskynneo | 0 | 4,425,983,158,874 | 57% | ||
val-b | 0 | 8,060,728,129,774 | 57% | ||
wackou | 0 | 745,059,709,171 | 15% | ||
kushed | 0 | 2,603,006,108,208 | 100% | ||
silver | 0 | 504,248,100,194 | 57% | ||
silversteem | 0 | 967,296,198,365 | 57% | ||
nextgencrypto | 0 | 2,421,331,520,741 | 57% | ||
rossco99 | 0 | 105,685,740,227 | 18% | ||
wang | 0 | 151,406,284,418 | 51% | ||
jaewoocho | 0 | 1,853,903,315,839 | 57% | ||
xeroc | 0 | 170,862,516,066 | 18% | ||
clayop | 0 | 1,666,967,793,917 | 57% | ||
lovejoy | 0 | 21,994,601,808 | 18% | ||
boatymcboatface | 0 | 36,409,465,215 | 18% | ||
pairmike | 0 | 7,277,737,233 | 18% | ||
donkeypong | 0 | 1,167,034,688,446 | 50% | ||
hcf27 | 0 | 4,775,156,267 | 60% | ||
ash | 0 | 55,915,648,230 | 60% | ||
acidsun | 0 | 16,138,882,275 | 30% | ||
steemship | 0 | 553,063,342,716 | 60% | ||
murh | 0 | 812,476,400 | 5% | ||
blakemiles84 | 0 | 32,961,184,971 | 18% | ||
theshell | 0 | 7,209,899,172 | 18% | ||
brich | 0 | 2,407,374,284 | 15% | ||
ratel | 0 | 10,207,159,314 | 60% | ||
michaelx | 0 | 3,468,629,859 | 18% | ||
anwenbaumeister | 0 | 547,580,048,163 | 60% | ||
albertogm | 0 | 3,983,171,098 | 18% | ||
tyler-fletcher | 0 | 2,726,160,231 | 60% | ||
fyrstikken | 0 | 112,412,044,083 | 5% | ||
clement | 0 | 6,068,195,287 | 60% | ||
isteemit | 0 | 26,490,939,146 | 60% | ||
skapaneas | 0 | 10,410,290,878 | 60% | ||
thebatchman | 0 | 1,118,526,059 | 3% | ||
asmolokalo | 0 | 53,014,743,983 | 33% | ||
lehard | 0 | 13,468,901,068 | 60% | ||
kakradetome | 0 | 10,865,180,496 | 100% | ||
furion | 0 | 6,067,150,570 | 2% | ||
on0tole | 0 | 8,516,844,428 | 60% | ||
anasya | 0 | 18,055,928,278 | 60% | ||
vl248 | 0 | 6,568,545,258 | 60% | ||
sveokla | 0 | 3,944,423,744 | 60% | ||
anyx | 0 | 89,597,280,827 | 15% | ||
marinabogumil | 0 | 4,899,125,248 | 60% | ||
anmuravjev | 0 | 1,738,485,079 | 60% | ||
raymondspeaks | 0 | 1,392,497,210 | 18% | ||
kell234 | 0 | 1,600,481,311 | 60% | ||
thebatchman1 | 0 | 69,192,335 | 3% | ||
pkattera | 0 | 39,397,130,457 | 15% | ||
hyiparena | 0 | 3,651,736,769 | 60% | ||
cryptojoy.com | 0 | 298,309,727 | 18% | ||
konti | 0 | 4,519,087,769 | 60% | ||
phenom | 0 | 2,631,098,757 | 18% | ||
fubar-bdhr | 0 | 26,710,163,159 | 30% | ||
bitcoiner | 0 | 2,835,420,775 | 18% | ||
sharker | 0 | 7,260,774,786 | 60% | ||
zaebars | 0 | 42,476,659,907 | 60% | ||
jedau | 0 | 3,069,771,546 | 60% | ||
mondeja | 0 | 2,572,971,824 | 60% | ||
crypto.owl | 0 | 5,972,153,581 | 60% | ||
pinkisland | 0 | 36,351,132,630 | 100% | ||
bkkshadow | 0 | 1,298,590,910 | 1.8% | ||
smailer | 0 | 37,227,631,591 | 60% | ||
dmilash | 0 | 12,077,712,332 | 60% | ||
shortcut | 0 | 30,355,025,841 | 36% | ||
gomeravibz | 0 | 6,846,560,055 | 18% | ||
litrbooh | 0 | 1,840,554,010 | 60% | ||
nekromarinist | 0 | 18,029,840,379 | 60% | ||
always1success | 0 | 3,955,614,959 | 60% | ||
brendio | 0 | 9,491,321,424 | 14.4% | ||
asdes | 0 | 2,974,379,885 | 60% | ||
mama-steem | 0 | 1,250,499,559 | 60% | ||
uuuhha | 0 | 10,275,712,716 | 60% | ||
romancs | 0 | 2,392,077,041 | 60% | ||
ipumba | 0 | 2,510,376,513 | 60% | ||
bigsambucca | 0 | 281,819,363 | 60% | ||
steemradio | 0 | 206,291,078 | 18% | ||
randyclemens | 0 | 10,220,567,028 | 60% | ||
krishtopa | 0 | 48,019,038,877 | 60% | ||
villainblack | 0 | 4,723,108,341 | 60% | ||
cmorton | 0 | 424,100,387 | 7.2% | ||
numberone | 0 | 3,022,079,633 | 60% | ||
bhavnapatel68 | 0 | 40,290,664,138 | 100% | ||
matrixdweller | 0 | 578,747,469 | 1% | ||
virtualgrowth | 0 | 1,144,023,847 | 3% | ||
jayfox | 0 | 386,864,068 | 18% | ||
craigwilliamz | 0 | 4,902,072,191 | 100% | ||
imag1ne | 0 | 1,575,135,452 | 60% | ||
leno4ek | 0 | 1,146,151,273 | 60% | ||
nulliusinverba | 0 | 897,813,247 | 18% | ||
shenanigator | 0 | 311,667,400,543 | 100% | ||
ashleywilliamz | 0 | 1,526,931,181 | 100% | ||
nadin3 | 0 | 4,826,833,886 | 60% | ||
xanoxt | 0 | 17,322,336,352 | 60% | ||
victoriart | 0 | 7,676,331,283 | 60% | ||
l0k1 | 0 | 2,548,422,082 | 1.8% | ||
maryfromsochi | 0 | 1,677,202,591 | 60% | ||
tatianka | 0 | 1,748,310,206 | 60% | ||
thecyclist | 0 | 1,148,786,357,548 | 57% | ||
zettar | 0 | 1,048,170,957 | 60% | ||
jacobts | 0 | 3,243,304,126 | 36% | ||
elena-singer | 0 | 4,811,517,535 | 60% | ||
renzoarg | 0 | 8,286,839,063 | 60% | ||
tracemayer | 0 | 4,783,431,373 | 18% | ||
burnin | 0 | 7,772,851,994 | 60% | ||
anton333 | 0 | 4,619,857,587 | 60% | ||
steemsquad | 0 | 1,483,425,440 | 60% | ||
ekaterinka | 0 | 1,608,161,561 | 60% | ||
drac59 | 0 | 2,787,276,478 | 100% | ||
develcuy | 0 | 2,944,834,350 | 60% | ||
borishaifa | 0 | 5,495,435,478 | 60% | ||
mapalatv | 0 | 1,218,360,023 | 60% | ||
meerkat | 0 | 1,151,901,817 | 21% | ||
thegame | 0 | 103,749,589 | 1.5% | ||
steembets | 0 | 105,367,418 | 1.5% | ||
crimson | 0 | 439,986,712 | 57% | ||
curie | 0 | 454,988,423,454 | 60% | ||
htyfn | 0 | 1,820,798,757 | 60% | ||
rusteemitblog | 0 | 4,905,058,450 | 60% | ||
therajmahal | 0 | 1,783,268,996 | 60% | ||
hendrikdegrote | 0 | 5,271,988,079,482 | 57% | ||
marel | 0 | 1,089,205,496 | 60% | ||
steemlift | 0 | 2,332,017,458 | 60% | ||
galveston | 0 | 2,387,981,609 | 57% | ||
oshima | 0 | 352,951,508 | 57% | ||
revostrike | 0 | 66,678,243 | 15% | ||
ianboil | 0 | 686,046,580 | 18% | ||
zatrhas | 0 | 1,619,838,162 | 30% | ||
zathras | 0 | 2,151,509,175 | 30% | ||
steemspeak | 0 | 225,969,877 | 2% | ||
fyrst-witness | 0 | 355,655,276 | 2% | ||
max-max | 0 | 2,549,265,587 | 60% | ||
sstefan | 0 | 1,313,899,011 | 10.8% | ||
garvofe | 0 | 3,380,905,652 | 60% | ||
steemland.com | 0 | 105,150,937 | 1.5% | ||
sqube | 0 | 2,953,544,383 | 3% | ||
chiliec | 0 | 1,399,906,917 | 7.5% | ||
steemprentice | 0 | 2,262,853,069 | 4.5% | ||
reisman | 0 | 2,892,309,356 | 100% | ||
engagement | 0 | 1,906,753,705,534 | 57% | ||
vcelier | 0 | 71,343,295,171 | 15% | ||
gildar | 0 | 678,048,079 | 60% | ||
dreemit | 0 | 1,949,063,933 | 6% | ||
killuminatic | 0 | 230,756,281 | 60% | ||
tonicbbleking | 0 | 796,821,461 | 60% | ||
tamersameeh | 0 | 299,220,598 | 60% | ||
beerbot | 0 | 1,499,946,582 | 30% | ||
fisteganos | 0 | 840,409,631 | 60% | ||
cgame | 0 | 2,017,861,418 | 100% | ||
blockained | 0 | 125,184,423 | 60% | ||
blockchained | 0 | 455,796,636 | 60% | ||
marco.world | 0 | 125,184,378 | 60% | ||
robertneleson | 0 | 550,092,057 | 60% | ||
vrezh | 0 | 93,449,397 | 60% | ||
pablo.ramalho | 0 | 87,914,070 | 100% |
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.
author | chaten |
---|---|
permlink | re-kakradetome-5-12-maximum-of-two-values-python-20170127t173713421z |
category | programming |
json_metadata | {"tags":["programming"],"links":["https://docs.python.org/3/library/functions.html#max"],"app":"steemit/0.1"} |
created | 2017-01-27 17:37:15 |
last_update | 2017-01-27 17:39:00 |
depth | 1 |
children | 3 |
last_payout | 2017-02-27 14:53:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 562 |
author_reputation | 1,986,564,144,965 |
root_title | "5.12 Maximum of Two Values - Python" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 2,358,958 |
net_rshares | 10,872,040,921 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
kakradetome | 0 | 10,872,040,921 | 100% |
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 :)
author | kakradetome |
---|---|
permlink | re-chaten-re-kakradetome-5-12-maximum-of-two-values-python-20170127t182319605z |
category | programming |
json_metadata | {"tags":["programming"],"users":["chaten"],"app":"steemit/0.1"} |
created | 2017-01-27 18:23:21 |
last_update | 2017-01-27 22:43:51 |
depth | 2 |
children | 2 |
last_payout | 2017-02-27 14:53:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,270 |
author_reputation | 31,794,084,266,065 |
root_title | "5.12 Maximum of Two Values - Python" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 2,359,241 |
net_rshares | 0 |
:D
author | chaten |
---|---|
permlink | re-kakradetome-re-chaten-re-kakradetome-5-12-maximum-of-two-values-python-20170127t215643265z |
category | programming |
json_metadata | {"tags":["programming"],"app":"steemit/0.1"} |
created | 2017-01-27 21:56:45 |
last_update | 2017-01-27 21:56:45 |
depth | 3 |
children | 1 |
last_payout | 2017-02-27 14:53:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 2 |
author_reputation | 1,986,564,144,965 |
root_title | "5.12 Maximum of Two Values - Python" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 2,360,550 |
net_rshares | 10,872,186,885 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
kakradetome | 0 | 10,872,186,885 | 100% |