Skip to content

Commit 04bbe54

Browse files
Cosmetics
1 parent 493699f commit 04bbe54

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed

notebooks/03_recursion_and_induction.ipynb

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@
568568
},
569569
{
570570
"cell_type": "code",
571-
"execution_count": 2,
571+
"execution_count": 12,
572572
"metadata": {},
573573
"outputs": [],
574574
"source": [
@@ -592,7 +592,7 @@
592592
},
593593
{
594594
"cell_type": "code",
595-
"execution_count": 3,
595+
"execution_count": 13,
596596
"metadata": {},
597597
"outputs": [
598598
{
@@ -619,7 +619,7 @@
619619
},
620620
{
621621
"cell_type": "code",
622-
"execution_count": 4,
622+
"execution_count": 14,
623623
"metadata": {},
624624
"outputs": [
625625
{
@@ -662,6 +662,46 @@
662662
"source": [
663663
"Or how much money will I have after a year?"
664664
]
665+
},
666+
{
667+
"cell_type": "code",
668+
"execution_count": 15,
669+
"metadata": {},
670+
"outputs": [
671+
{
672+
"name": "stdout",
673+
"output_type": "stream",
674+
"text": [
675+
"If you start with $1000 and earn 2% a day,\n",
676+
"on day 365 you will have more than $1350400!\n"
677+
]
678+
}
679+
],
680+
"source": [
681+
"def how_much_money(starting_amount, earn_percent, day):\n",
682+
" daily_factor = 1 + (earn_percent / 100.0)\n",
683+
" return starting_amount * (daily_factor ** (day - 1))\n",
684+
"\n",
685+
"\n",
686+
"def print_example(starting_amount, earn_percent, day):\n",
687+
" money = int(how_much_money(starting_amount,\n",
688+
" earn_percent, day))\n",
689+
"\n",
690+
" print(f\"If you start with ${starting_amount} \"\n",
691+
" f\"and earn {earn_percent}% a day,\"\n",
692+
" f\"\\non day {day} you will have \"\n",
693+
" f\"more than ${money}!\")\n",
694+
"\n",
695+
"\n",
696+
"print_example(1000, 2, 365)"
697+
]
698+
},
699+
{
700+
"cell_type": "code",
701+
"execution_count": null,
702+
"metadata": {},
703+
"outputs": [],
704+
"source": []
665705
}
666706
],
667707
"metadata": {

0 commit comments

Comments
 (0)