diff options
author | hardythe1 | 2015-05-05 14:21:39 +0530 |
---|---|---|
committer | hardythe1 | 2015-05-05 14:21:39 +0530 |
commit | 435840cef00c596d9e608f9eb2d96f522ea8505a (patch) | |
tree | 4c783890c984c67022977ca98432e5e4bab30678 /Elements_of_discrete_mathematics/Chapter8.ipynb | |
parent | aa1863f344766ca7f7c20a395e58d0fb23c52130 (diff) | |
download | Python-Textbook-Companions-435840cef00c596d9e608f9eb2d96f522ea8505a.tar.gz Python-Textbook-Companions-435840cef00c596d9e608f9eb2d96f522ea8505a.tar.bz2 Python-Textbook-Companions-435840cef00c596d9e608f9eb2d96f522ea8505a.zip |
add books
Diffstat (limited to 'Elements_of_discrete_mathematics/Chapter8.ipynb')
-rwxr-xr-x | Elements_of_discrete_mathematics/Chapter8.ipynb | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/Elements_of_discrete_mathematics/Chapter8.ipynb b/Elements_of_discrete_mathematics/Chapter8.ipynb new file mode 100755 index 00000000..a92071c6 --- /dev/null +++ b/Elements_of_discrete_mathematics/Chapter8.ipynb @@ -0,0 +1,62 @@ +{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:315aef45dcd0f156b4319ee68cddb70a9a8edfeb1c485c709f025d64bf2af90b"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "8 Discrete numeric functions and generating functions"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 01:Page 368"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "print \"Suppose we deposit $100 in a savings account at an interest rate of 7 percent per year, compounded annually\"\n",
+ "principal=100\n",
+ "rate_of_interest=7\n",
+ "def amount(r): # r represents the number of years\n",
+ " a=principal*pow(1.07,r) # Since the formula for compound interest is 100*(1+(rate_of_interest/100)) and rate_of_interest here is 7\n",
+ " return a\n",
+ "print \"At the end of the first year, the total amount in the account is $\",amount(1) #Since we calculate the amount after 1 year, here r is 1\n",
+ "print \"At the end of the second year, the total amount in the account is $\",amount(2) #Since we calculate the amount after 2 years, here r is 2\n",
+ "print \"At the end of the third year, the total amount in the account is $\",round(amount(3),2) #Since we calculate the amount after 3 years, here r is 3\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Suppose we deposit $100 in a savings account at an interest rate of 7 percent per year, compounded annually\n",
+ "At the end of the first year, the total amount in the account is $ 107.0\n",
+ "At the end of the second year, the total amount in the account is $ 114.49\n",
+ "At the end of the third year, the total amount in the account is $ 122.5\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+}
\ No newline at end of file |