diff options
author | Jovina Dsouza | 2014-07-07 16:34:28 +0530 |
---|---|---|
committer | Jovina Dsouza | 2014-07-07 16:34:28 +0530 |
commit | fffcc90da91b66ee607066d410b57f34024bd1de (patch) | |
tree | 7b8011d61013305e0bf7794a275706abd1fdb0d3 /Beginning_C++_through_Game_Programming/ch4.ipynb | |
parent | 299711403e92ffa94a643fbd960c6f879639302c (diff) | |
download | Python-Textbook-Companions-fffcc90da91b66ee607066d410b57f34024bd1de.tar.gz Python-Textbook-Companions-fffcc90da91b66ee607066d410b57f34024bd1de.tar.bz2 Python-Textbook-Companions-fffcc90da91b66ee607066d410b57f34024bd1de.zip |
adding book
Diffstat (limited to 'Beginning_C++_through_Game_Programming/ch4.ipynb')
-rwxr-xr-x | Beginning_C++_through_Game_Programming/ch4.ipynb | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/Beginning_C++_through_Game_Programming/ch4.ipynb b/Beginning_C++_through_Game_Programming/ch4.ipynb new file mode 100755 index 00000000..08fbd2a9 --- /dev/null +++ b/Beginning_C++_through_Game_Programming/ch4.ipynb @@ -0,0 +1,112 @@ +{ + "metadata": { + "name": "ch4" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": "Chapter 4 : Conditionals and recursion" + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 4.1 page no :34" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\nexample 4.1 page no :34\n'''\n\ndef printParity (x):\n if (x%2 == 0):\n print \"x is even\" \n else:\n print \"x is odd\" \n\nprintParity (17)", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "x is odd\n" + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 4.2 page no :36" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\nexample 4.2 page no :36\n'''\nimport math\n\ndef printLogarithm (x):\n if (x <= 0.0):\n print \"Positive numbers only, please.\" \n return;\n result = math.log(x);\n print \"The log of x is \" , result;\n\nprintLogarithm(-1)\nprintLogarithm(5)", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Positive numbers only, please.\nThe log of x is 1.60943791243\n" + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 4.3 page no : 37" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\nexample 4.3 page no : 37\n'''\n\ndef countdown (n):\n if (n == 0):\n print \"Blastoff!\" \n else:\n print n\n countdown (n-1)\n\ncountdown(5)", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "5\n4\n3\n2\n1\nBlastoff!\n" + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 4.4\n" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\nexample 4.4\n'''\nimport math\ndef printLogarithm(x):\n if (x <= 0.0):\n print \"Positive numbers only, please.\" << endl;\n return;\n result = math.log(x)\n print \"The log of x is \" , result;\n\ndef countdown (n) :\n if (n == 0):\n print \"Blastoff!\"\n else:\n print n\n countdown (n-1);\n\n\ncountdown (3);\nprintLogarithm(10)", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "3\n2\n1\nBlastoff!\nThe log of x is 2.30258509299\n" + } + ], + "prompt_number": 4 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "", + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file |