summaryrefslogtreecommitdiff
path: root/Beginning_C++_through_Game_Programming/ch10.ipynb
diff options
context:
space:
mode:
authorJovina Dsouza2014-07-07 16:34:28 +0530
committerJovina Dsouza2014-07-07 16:34:28 +0530
commitfffcc90da91b66ee607066d410b57f34024bd1de (patch)
tree7b8011d61013305e0bf7794a275706abd1fdb0d3 /Beginning_C++_through_Game_Programming/ch10.ipynb
parent299711403e92ffa94a643fbd960c6f879639302c (diff)
downloadPython-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/ch10.ipynb')
-rwxr-xr-xBeginning_C++_through_Game_Programming/ch10.ipynb142
1 files changed, 142 insertions, 0 deletions
diff --git a/Beginning_C++_through_Game_Programming/ch10.ipynb b/Beginning_C++_through_Game_Programming/ch10.ipynb
new file mode 100755
index 00000000..cd0445e0
--- /dev/null
+++ b/Beginning_C++_through_Game_Programming/ch10.ipynb
@@ -0,0 +1,142 @@
+{
+ "metadata": {
+ "name": "ch10"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": "CHAPTER 10. : VECTORS"
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": "example 10.1 page no :103\n"
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": "'''\nexample 10.1 page no :103\n''' \n\nvalues = [] \nc = int(raw_input())\nwhile(c != -1):\n values.append(c)\n c = int(raw_input())\n\nsize=len(values)\nfor i in range(size):\n print values[i] ",
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": "5\n"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": "4\n"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": "3\n"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": "2\n"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": "-1\n"
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": "5\n4\n3\n2\n"
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": "example 10.2 page no :104\n"
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": "'''\nexample 10.2 page no :104\n'''\nimport random\n\nfor i in range(4):\n x = random.random();\n print x",
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": "0.16979844903\n0.113100369897\n0.851107623696\n0.0966914962921\n"
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": "example 10.3 page no :105\n"
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": "'''\nexample 10.3 page no :105\n'''\nimport random\ndef randomVector(n,upperBound):\n vec = []\n for i in range(n):\n vec.append(random.random () * 100 % upperBound)\n return vec\n\ndef printVector(vec):\n for i in range(len(vec)):\n print vec[i] ,\n\nnumValues = 20;\nupperBound = 10;\nvector = randomVector (numValues, upperBound);\nprintVector(vector)",
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": "1.84318995426 8.49475291756 7.92488160107 3.93550646061 0.967457025838 6.72758767668 6.22192058422 8.19279912461 7.4898535715 3.02785494125 2.97556694487 4.70451449621 8.21039455753 2.95832700489 7.02858630112 8.72631899097 5.67567455024 7.48090989023 9.14911759876 9.82069257056\n"
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": "example 10.4 page no: 106\n"
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": "'''\nexample 10.4 page no: 106\n'''\nimport random\ndef howMany(vec,value):\n count = 0\n for i in range(len(vec)):\n if (vec[i] == value):\n count += 1\n return count\n\ndef randomVector(n,upperBound):\n vec = []\n for i in range(n):\n vec.append(int(random.random () * 100 % upperBound))\n return vec\n \nnumValues = 20;\nupperBound = 10;\nvector = randomVector (numValues, upperBound);\nprint \"value \\t howMany\"\nfor i in range(upperBound):\n print i , '\\t' , howMany(vector, i)",
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": "value \t howMany\n0 \t2\n1 \t2\n2 \t0\n3 \t4\n4 \t3\n5 \t1\n6 \t2\n7 \t1\n8 \t2\n9 \t3\n"
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": "",
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file