\n",
" "
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"'''calculate simple interest for a set of values representing principle,\n",
"number of years and rate of interest.'''\n",
"\n",
"#Variable declaration\n",
"p = 1000 #principle\n",
"n = 3 # number of years\n",
"r = 8.5 # rate of interest\n",
"\n",
"#Calculation\n",
"si = p * n * r / 100 ; #formula for simple interest\n",
"\n",
"#Result\n",
"print ( si )\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"255.0\n"
]
}
],
"prompt_number": 1
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"
Simple Interest, Page number: 21
"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"'''calculate simple interest by inputing principle,\n",
"number of years and rate of interest from the user.'''\n",
"\n",
"#Input from the user\n",
"#p,n,r = raw_input(\"Enter values of p, n, r : \").split()\n",
"p = 100 # principle\n",
"n = 5 # number of years\n",
"r = 15.5 # rate of interest\n",
"\n",
"#Calculation\n",
"si = p * n * r / 100 ; #formula for simple interest\n",
"\n",
"#Result\n",
"print ( si )\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"77.5\n"
]
}
],
"prompt_number": 2
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"
Just for fun, Page number: 22
"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"'''Just for fun. Author: Bozo'''\n",
"\n",
"#Input from the user\n",
"#num = raw_input(\"Enter a number : \")\n",
"num = 11\n",
"\n",
"#Result\n",
"print \"Now I am letting you on a secret...\" \n",
"print \"You have just entered the number\", num \n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Now I am letting you on a secret...\n",
"You have just entered the number 11\n"
]
}
],
"prompt_number": 4
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"