Viewing a response to: @filler/python-practice-tests
How come this outputs with 0? def print_nums(x): for i in range(x): print(i) return print_nums(10)
author | emrebeyler |
---|---|
permlink | q041dt |
category | coding |
json_metadata | {"app":"steemit/0.1"} |
created | 2019-10-29 00:29:54 |
last_update | 2019-10-29 00:29:54 |
depth | 1 |
children | 3 |
last_payout | 2019-11-05 00:29:54 |
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 | 100 |
author_reputation | 448,535,049,068,622 |
root_title | "Python practice tests" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 91,996,464 |
net_rshares | 5,577,140,777 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
ismailkah | 0 | 5,577,140,777 | 25% |
> return is a construction used in the code block of a function definition + after the return instruction is inserted the code block will stop executing anything so : > def print_nums(x): for i in range(x): print(i) return print_nums(10) > Program takes 0, verifies that is in range of 10 and prints 0 Because of the return statement program stops executing the code > If return is deleted from code the output will be 0 1 2 3 4 5 6 7 8 9
author | filler |
---|---|
permlink | q04d3d |
category | coding |
json_metadata | {"app":"steemit/0.1"} |
created | 2019-10-29 04:42:54 |
last_update | 2019-10-29 04:42:54 |
depth | 2 |
children | 2 |
last_payout | 2019-11-05 04:42:54 |
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 | 453 |
author_reputation | 4,924,532,976,740 |
root_title | "Python practice tests" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 92,000,955 |
net_rshares | 0 |
That depends on the indentation:-)
author | emrebeyler |
---|---|
permlink | q04iem |
category | coding |
json_metadata | {"app":"steemit/0.1"} |
created | 2019-10-29 06:37:36 |
last_update | 2019-10-29 06:37:36 |
depth | 3 |
children | 1 |
last_payout | 2019-11-05 06:37:36 |
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 | 34 |
author_reputation | 448,535,049,068,622 |
root_title | "Python practice tests" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 92,002,759 |
net_rshares | 5,554,864,179 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
ismailkah | 0 | 5,554,864,179 | 25% |
The indentation went wrong because of improper markdown
author | filler |
---|---|
permlink | q054xb |
category | coding |
json_metadata | {"app":"steemit/0.1"} |
created | 2019-10-29 14:44:06 |
last_update | 2019-10-29 14:44:06 |
depth | 4 |
children | 0 |
last_payout | 2019-11-05 14:44:06 |
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 | 55 |
author_reputation | 4,924,532,976,740 |
root_title | "Python practice tests" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 92,013,261 |
net_rshares | 0 |