|
568 | 568 | }, |
569 | 569 | { |
570 | 570 | "cell_type": "code", |
571 | | - "execution_count": 2, |
| 571 | + "execution_count": 12, |
572 | 572 | "metadata": {}, |
573 | 573 | "outputs": [], |
574 | 574 | "source": [ |
|
592 | 592 | }, |
593 | 593 | { |
594 | 594 | "cell_type": "code", |
595 | | - "execution_count": 3, |
| 595 | + "execution_count": 13, |
596 | 596 | "metadata": {}, |
597 | 597 | "outputs": [ |
598 | 598 | { |
|
619 | 619 | }, |
620 | 620 | { |
621 | 621 | "cell_type": "code", |
622 | | - "execution_count": 4, |
| 622 | + "execution_count": 14, |
623 | 623 | "metadata": {}, |
624 | 624 | "outputs": [ |
625 | 625 | { |
|
662 | 662 | "source": [ |
663 | 663 | "Or how much money will I have after a year?" |
664 | 664 | ] |
| 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": [] |
665 | 705 | } |
666 | 706 | ], |
667 | 707 | "metadata": { |
|
0 commit comments