diff options
author | Hardik Ghaghada | 2014-06-21 14:25:56 +0530 |
---|---|---|
committer | Hardik Ghaghada | 2014-06-21 14:25:56 +0530 |
commit | 299711403e92ffa94a643fbd960c6f879639302c (patch) | |
tree | 009cb02ec85f4a75ac7b64239751f15361df2bfe /Schaum's_Outlines_-_Programming_with_C++ | |
parent | e1e59ca3a50d9f93e8b7bc0693b8081d5db77771 (diff) | |
parent | 7c756fcc12d21693818e58f6936cab5b7c112868 (diff) | |
download | Python-Textbook-Companions-299711403e92ffa94a643fbd960c6f879639302c.tar.gz Python-Textbook-Companions-299711403e92ffa94a643fbd960c6f879639302c.tar.bz2 Python-Textbook-Companions-299711403e92ffa94a643fbd960c6f879639302c.zip |
Merge pull request #2 from debashisdeb/master
Removed Problem Statements Completely
Diffstat (limited to 'Schaum's_Outlines_-_Programming_with_C++')
-rw-r--r-- | Schaum's_Outlines_-_Programming_with_C++/ch1.ipynb | 11 | ||||
-rw-r--r-- | Schaum's_Outlines_-_Programming_with_C++/ch10.ipynb | 8 | ||||
-rw-r--r-- | Schaum's_Outlines_-_Programming_with_C++/ch11.ipynb | 36 | ||||
-rw-r--r-- | Schaum's_Outlines_-_Programming_with_C++/ch2.ipynb | 34 | ||||
-rw-r--r-- | Schaum's_Outlines_-_Programming_with_C++/ch4.ipynb | 4 | ||||
-rw-r--r-- | Schaum's_Outlines_-_Programming_with_C++/ch5.ipynb | 47 | ||||
-rw-r--r-- | Schaum's_Outlines_-_Programming_with_C++/ch6.ipynb | 15 |
7 files changed, 73 insertions, 82 deletions
diff --git a/Schaum's_Outlines_-_Programming_with_C++/ch1.ipynb b/Schaum's_Outlines_-_Programming_with_C++/ch1.ipynb index 7b82a76b..5ac1363a 100644 --- a/Schaum's_Outlines_-_Programming_with_C++/ch1.ipynb +++ b/Schaum's_Outlines_-_Programming_with_C++/ch1.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:4e45f4199722574c1e72ad7420d88b009a90aed0de40180b69c61cfde130a1dd" + "signature": "sha256:1f4ff165c5b37e972fbde6114f5c4644c7b325a65e411fa21e1921b02d662bf7" }, "nbformat": 3, "nbformat_minor": 0, @@ -57,7 +57,6 @@ "input": [ "\n", "\n", - "# prints \"Hello, World!\":\n", "print \"Hel\" + \"lo, Wo\" + \"rld!\" \n", "\n" ], @@ -80,7 +79,6 @@ "input": [ "\n", "\n", - "# prints \"Hello, World!\":\n", "print \"Hello, W\" + 'o' + \"rld\" + '!' " ], "language": "python", @@ -102,7 +100,6 @@ "input": [ "\n", "\n", - "# prints \"The Millennium ends Dec 31 2000.\":\n", "print \"The Millennium ends Dec %d %d \" %(31,2000)" ], "language": "python", @@ -124,7 +121,6 @@ "input": [ "\n", "\n", - "# prints \"m = 44 and n = 77\":\n", "\n", "m = 44 # assigns the value 44 to the variable m\n", "print \"m = %d \" % m,\n", @@ -150,7 +146,6 @@ "input": [ "\n", "\n", - "# prints \"n = 44:\n", "n=44\n", "print \"n = %d\" % n" ], @@ -173,7 +168,6 @@ "input": [ "\n", "\n", - "# Python does not have semicolons so wont give any errors.\n", "n=44\n", "print \"n = %d\" % n " ], @@ -195,8 +189,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "# prints \"m = ?? and n = 44\":\n", "m = 0 #In python we do not have declaration of variables, we just initialize it and use it.\n", "n=44\n", "print \"m = %d and n = %d\" %(m,n)" @@ -219,7 +211,6 @@ "collapsed": false, "input": [ "\n", - "# defines constants; has no output:\n", "BEEP = '\\b'\n", "MAXINT = 2147483647\n", "N = MAXINT/2\n", diff --git a/Schaum's_Outlines_-_Programming_with_C++/ch10.ipynb b/Schaum's_Outlines_-_Programming_with_C++/ch10.ipynb index febb60a4..20eeb516 100644 --- a/Schaum's_Outlines_-_Programming_with_C++/ch10.ipynb +++ b/Schaum's_Outlines_-_Programming_with_C++/ch10.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:bbd6687393c06a730c7f5060250758a1f9af1de5ce96291cc9b90cec582f1aa5" + "signature": "sha256:6ab29bd91e48ed72112d302e0e8b3ba6e41a906b6302b14581de985939de5731" }, "nbformat": 3, "nbformat_minor": 0, @@ -238,7 +238,7 @@ "input": [ "\n", "def gcd(m,n):\n", - " # returns the greatest common divisor of m and n:\n", + " \n", " if (m<n):\n", " m,n = n,m\n", " while (n>0):\n", @@ -303,7 +303,7 @@ "input": [ "\n", "def gcd(m,n):\n", - " # returns the greatest common divisor of m and n:\n", + " \n", " if (m<n):\n", " m,n = n,m\n", " while (n>0):\n", @@ -376,7 +376,7 @@ "input": [ "\n", "def gcd(m,n):\n", - " # returns the greatest common divisor of m and n:\n", + " \n", " if (m<n):\n", " m,n = n,m\n", " while (n>0):\n", diff --git a/Schaum's_Outlines_-_Programming_with_C++/ch11.ipynb b/Schaum's_Outlines_-_Programming_with_C++/ch11.ipynb index 34fb61dc..d65c28e3 100644 --- a/Schaum's_Outlines_-_Programming_with_C++/ch11.ipynb +++ b/Schaum's_Outlines_-_Programming_with_C++/ch11.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:bdd5f9e441ccb7e3a87f4d8c5492d0aa1d228caba299fc1b0c667abb12780a1e" + "signature": "sha256:e48eb1ccc0a3bcda7cfb3c8c85a4d3a8e98cd5fdd1c8b0533a2ba81289b5dcbf" }, "nbformat": 3, "nbformat_minor": 0, @@ -106,7 +106,7 @@ "input": [ "\n", "def gcd(m,n):\n", - " # returns the greatest common divisor of m and n:\n", + " \n", " if (m<n):\n", " m,n = n,m\n", " while (n>0):\n", @@ -175,7 +175,7 @@ "input": [ "\n", "def gcd(m,n):\n", - " # returns the greatest common divisor of m and n:\n", + " \n", " if (m<n):\n", " m,n = n,m\n", " while (n>0):\n", @@ -277,7 +277,7 @@ "input": [ "\n", "def gcd(m,n):\n", - " # returns the greatest common divisor of m and n:\n", + "\n", " if (m<n):\n", " m,n = n,m\n", " while (n>0):\n", @@ -382,7 +382,7 @@ "input": [ "\n", "def gcd(m,n):\n", - " # returns the greatest common divisor of m and n:\n", + "\n", " if (m<n):\n", " m,n = n,m\n", " while (n>0):\n", @@ -461,7 +461,7 @@ "input": [ "\n", "def gcd(m,n):\n", - " # returns the greatest common divisor of m and n:\n", + " \n", " if (m<n):\n", " m,n = n,m\n", " while (n>0):\n", @@ -533,7 +533,7 @@ "input": [ "\n", "def gcd(m,n):\n", - " # returns the greatest common divisor of m and n:\n", + " \n", " if (m<n):\n", " m,n = n,m\n", " while (n>0):\n", @@ -606,7 +606,7 @@ "input": [ "\n", "def gcd(m,n):\n", - " # returns the greatest common divisor of m and n:\n", + " \n", " if (m<n):\n", " m,n = n,m\n", " while (n>0):\n", @@ -669,7 +669,25 @@ ] } ], - "prompt_number": 7 + "prompt_number": 2 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 }, { "cell_type": "code", diff --git a/Schaum's_Outlines_-_Programming_with_C++/ch2.ipynb b/Schaum's_Outlines_-_Programming_with_C++/ch2.ipynb index 52984e73..b03e0beb 100644 --- a/Schaum's_Outlines_-_Programming_with_C++/ch2.ipynb +++ b/Schaum's_Outlines_-_Programming_with_C++/ch2.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:43f850ff4e8965af5c5db1b79b7b4f60c3104eca56084bd90dc829928ca10593" + "signature": "sha256:b7fd8e305f82250735b733aadfdbd451b8947aadb96283663ae0092c6c46c8ec" }, "nbformat": 3, "nbformat_minor": 0, @@ -13,7 +13,6 @@ "collapsed": false, "input": [ "\n", - "# prints the value of a boolean variable:\n", "flag=False\n", "print \"flag = %r\" % flag\n", "flag = True\n", @@ -39,7 +38,7 @@ "input": [ "\n", "\n", - "# prints the character and its internally stored\n", + "\n", "c='A'\n", "print \"c = \" + c + \", int(c) = %d\" % ord(c)\n", "c='t'\n", @@ -71,7 +70,7 @@ "input": [ "\n", "import sys\n", - "# defines the constants SHRT_MIN, etc.\n", + "\n", "print 'maximum limit int : ',\n", "print sys.maxint\n", "print 'float info'\n", @@ -97,7 +96,6 @@ "collapsed": false, "input": [ "\n", - "# tests operators +, -, *, /, and %:\n", "m=54\n", "n=20\n", "print \"m = %d and n = %d\" %(m,n)\n", @@ -131,7 +129,7 @@ "input": [ "\n", "\n", - "# shows the difference between m++ and ++m:\n", + "\n", "m = 44\n", "m += 1\n", "n = m\n", @@ -160,8 +158,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "# tests arithmetic assignment operators:\n", "n=22\n", "print \"n = %d\" % n\n", "n += 9 # adds 9 to n\n", @@ -198,7 +194,7 @@ "collapsed": false, "input": [ "\n", - "# tests the floating-point operators +, -, *, and /:\n", + "\n", "x=54.0\n", "y=20.0\n", "print \"x = %f and y = %f\" %(x,y)\n", @@ -230,7 +226,7 @@ "input": [ "\n", "import sys\n", - "# prints the storage sizes of the fundamental types:\n", + "\n", "print \"Number of bytes used:\\n\"\n", "\n", "print \" char: %d \" % sys.getsizeof('a')\n", @@ -262,7 +258,7 @@ "input": [ "\n", "import sys\n", - "# prints the storage sizes of the fundamental types:\n", + "\n", "fbits = 8*sys.getsizeof(float(123))\n", "\n", "# each byte contains 8 bits\n", @@ -287,7 +283,6 @@ "collapsed": false, "input": [ "\n", - "# casts a double value as an int:\n", "v = 1234.56789\n", "n = int(v);\n", "print \"v = %f, n = %d\" %(v,n)" @@ -310,7 +305,6 @@ "collapsed": false, "input": [ "\n", - "# prints promoted vales of 65 from char to double:\n", "c='A'\n", "print \"char c = \" + c\n", "k=c;\n", @@ -347,7 +341,6 @@ "collapsed": false, "input": [ "\n", - "# prints n until it overflows:\n", "n=1000\n", "print \"n = %d\" % n\n", "n *= 1000 # multiplies n by 1000\n", @@ -378,7 +371,6 @@ "collapsed": false, "input": [ "\n", - "# prints x until it overflows:\n", "x=1000.0\n", "print \"x = %f\" % x\n", "x *= x # multiplies n by itself; i.e., it squares x\n", @@ -412,7 +404,7 @@ "collapsed": false, "input": [ "\n", - "# illustrates round-off error::\n", + "\n", "x = 1000/3.0\n", "print \"x = %f\" %x # x = 1000/3\n", "y = x - 333.0\n", @@ -448,7 +440,7 @@ "\n", "import math\n", "\n", - "# implements the quadratic formula\n", + "\n", "a = float(raw_input(\"Enter the coefficients of a quadratic equation:\\n a : \"))\n", "b = float(raw_input('b : '))\n", "c = float(raw_input('c : '))\n", @@ -521,8 +513,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "# prints double values in scientific e-format:\n", "x = float(raw_input(\"Enter float: \"))\n", "print \"Its reciprocal is: \",\n", "print 1/x " @@ -553,9 +543,7 @@ "collapsed": false, "input": [ "\n", - "# illustrates the scope of variables:\n", - "x = 11\n", - "# ERROR: this is not in the scope of x\n", + "x = 11 \n", "if True:\n", " x = 22 # OK: this is in the scope of x\n", " y = 33 # ERROR: this is not in the scope of y\n", @@ -574,7 +562,7 @@ "collapsed": false, "input": [ "\n", - "# this x is global\n", + "\n", "x = 11\n", "\n", "if True:\n", diff --git a/Schaum's_Outlines_-_Programming_with_C++/ch4.ipynb b/Schaum's_Outlines_-_Programming_with_C++/ch4.ipynb index 3c0afba2..64e8a763 100644 --- a/Schaum's_Outlines_-_Programming_with_C++/ch4.ipynb +++ b/Schaum's_Outlines_-_Programming_with_C++/ch4.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:f4ac3c8a3319ce3724a4367884b8f78c4152f64a5f7a4c1bcc6365ff895fb824" + "signature": "sha256:7bd00720050ed2a3657363e38f1e369105d66f3738b7a484e8db28626c8d8a4e" }, "nbformat": 3, "nbformat_minor": 0, @@ -911,7 +911,7 @@ "input": [ "\n", "import math\n", - "# defines pow() and log()\n", + "\n", "\n", "print \"Enter a positive integer: \"\n", "n = int(raw_input())\n", diff --git a/Schaum's_Outlines_-_Programming_with_C++/ch5.ipynb b/Schaum's_Outlines_-_Programming_with_C++/ch5.ipynb index e3de2713..f2c1f873 100644 --- a/Schaum's_Outlines_-_Programming_with_C++/ch5.ipynb +++ b/Schaum's_Outlines_-_Programming_with_C++/ch5.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:24e76f61ba45b924df39848fa855d4479d9e602e3e0935f26f67699be40eb3ff" + "signature": "sha256:08f28df467a1f0a941ab1bf603885e6d5dd4e19b6b21d49fd2ef0604a23f5de2" }, "nbformat": 3, "nbformat_minor": 0, @@ -14,8 +14,7 @@ "input": [ "\n", "import math\n", - "\n", - "# tests the sqrt() function:\n", + ":\n", "for i in range(0,6):\n", " print \"\\t %d \\t %f\" %(i,math.sqrt(i))" ], @@ -43,7 +42,7 @@ "input": [ "\n", "import math\n", - "# tests the identity sin 2x = 2 sin x cos x:\n", + "\n", "x = 0\n", "while x < 2:\n", " print \"%f \\t\\t %f \\t %f\" %(x,math.sin(2*x),2*math.sin(x)*math.cos(x))\n", @@ -80,7 +79,7 @@ "\n", "\n", "def cube(x):\n", - " # returns cube of x:\n", + " \n", " return x*x*x\n", "\n" ], @@ -96,10 +95,10 @@ "\n", "\n", "def cube(x):\n", - " # returns cube of x:\n", + " \n", " return x*x*x\n", "\n", - "# tests the cube() function:\n", + "\n", "n=1\n", "while (n != 0):\n", " n = int(raw_input())\n", @@ -177,7 +176,7 @@ "input": [ "\n", "def maximum(x,y):\n", - " # returns larger of the two given integers:\n", + " \n", " if (x < y):\n", " return y\n", " else:\n", @@ -250,7 +249,7 @@ "input": [ "\n", "def maximum(x,y):\n", - " # returns larger of the two given integers:\n", + " \n", " if (x < y):\n", " return y\n", " else:\n", @@ -323,7 +322,6 @@ "input": [ "\n", "\n", - "# returns larger of the two given integers:\n", "\n", "m = 1\n", "n = 1\n", @@ -476,7 +474,7 @@ "\n", "\n", "def perm(n,k):\n", - " # returns P(n,k), the number of permutations of k from n:\n", + " \n", " if (n < 0 or k < 0 or k > n):\n", " return 0\n", " return fact(n)/fact(n-k)\n", @@ -514,7 +512,7 @@ "\n", "\n", "def printDate(m,d,y):\n", - " # prints the given date in literal form:\n", + " \n", " if (m < 1 or m > 12 or d < 1 or d > 31 or y < 0):\n", " print \"Error: parameter out of range.\\n\"\n", " return\n", @@ -630,7 +628,7 @@ "def ispunct(s):\n", " return all(c in string.punctuation for c in s)\n", "def printCharCategory(c):\n", - " # prints the category to which the given character belongs:\n", + " \n", " print \"The character [\" + c + \"] is a \",\n", " if(c.isdigit()):\n", " print \"digit.\\n\"\n", @@ -934,7 +932,7 @@ "\n", "import math\n", "def isPrime(n):\n", - " # returns True if n is prime, False otherwise:\n", + "\n", " sqrtn = math.sqrt(n)\n", " if (n < 2):\n", " return False\n", @@ -974,7 +972,7 @@ "input": [ "\n", "def isLeapYear(y):\n", - " # returns true iff y is a leap year:\n", + " \n", " return (y % 4 == 0 and y % 100 != 0 or y % 400 == 0)\n", "\n", "# tests the isLeapYear() function:\n", @@ -1059,7 +1057,7 @@ "\n", "\n", "def age():\n", - " # prompts the user to input his/her age, and returns that value:\n", + " \n", " while (True):\n", " print \"How old are you: \"\n", " n = int(raw_input())\n", @@ -1148,7 +1146,7 @@ "\n", "\n", "def swap(x,y):\n", - " # exchanges the values of x and y:\n", + " \n", " x[0],y[0] = y[0],x[0]\n", "\n", "a = [22.2]\n", @@ -1181,7 +1179,6 @@ " x[0]= 88\n", " y[0] = 99\n", "\n", - "# tests the f() function:\n", "a = [22]\n", "b = [44]\n", "print \"a = %.2f , b = %.2f \" %(a[0],b[0])\n", @@ -1212,7 +1209,7 @@ "\n", "\n", "def computeCircle(r):\n", - " # returns the area and circumference of a circle with radius r:\n", + " \n", " PI = 3.141592653589793\n", " area = PI*r*r\n", " circumference = 2*PI*r\n", @@ -1296,10 +1293,10 @@ "input": [ "\n", "def cube(x):\n", - " # returns cube of x:\n", + " \n", " return x*x*x\n", "\n", - "# tests the cube() function:\n", + ":\n", "print cube(4)\n", "x = int(raw_input())\n", "y = cube(2*x-3)\n", @@ -1408,8 +1405,6 @@ "collapsed": false, "input": [ "\n", - "\n", - "# prints the quotient of two input integers:\n", "print \"Enter two integers: \"\n", "n = int(raw_input())\n", "d = int(raw_input())\n", @@ -1461,7 +1456,7 @@ "input": [ "\n", "def reciprocal(x):\n", - " #returns the reciprocal of x:\n", + " \n", " if (x == 0):\n", " import sys\n", " sys.exit(1); # terminate the program\n", @@ -1497,11 +1492,11 @@ "input": [ "\n", "def p(x,a0,a1=0,a2=0,a3=0):\n", - " # returns a0 + a1*x + a2*x^2 + a3*x^3:\n", + "\n", " return (a0 + (a1 + (a2 + a3*x)*x)*x)\n", "\n", "\n", - "# tests the p() function:\n", + "\n", "x = 2.0003\n", "print \"p(x,7) = %f\" % p(x,7)\n", "print \"p(x,7,6) = %f\" % p(x,7,6)\n", diff --git a/Schaum's_Outlines_-_Programming_with_C++/ch6.ipynb b/Schaum's_Outlines_-_Programming_with_C++/ch6.ipynb index 191b1c78..0ed8b9bb 100644 --- a/Schaum's_Outlines_-_Programming_with_C++/ch6.ipynb +++ b/Schaum's_Outlines_-_Programming_with_C++/ch6.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:002670bb2c70e6ed5cc1d52c3936c4a90e901b6c8d78abcf5af4402c27118a1a" + "signature": "sha256:d63f30088951026ca8431b2db000283f5d2b32b8fd4852f840cfd94c7913a4ff" }, "nbformat": 3, "nbformat_minor": 0, @@ -45,7 +45,7 @@ "\n", "SIZE=5 # defines the size N for 5 elements\n", "a = []\n", - "# declares the array's elements as type double\n", + "\n", "print \"Enter \" , SIZE , \" numbers:\\t\"\n", "for i in range(SIZE):\n", " a.append(float(raw_input()))\n", @@ -186,7 +186,7 @@ "import numpy\n", "SIZE = 4\n", "a = numpy.zeros(4)\n", - "# declares the array's elements as type float\n", + "\n", "for i in range(SIZE):\n", " print \"\\ta[\" , i , \"] = \" , a[i]\n" ], @@ -479,7 +479,7 @@ "input": [ "\n", "def sort(a,n):\n", - " # bubble sort:\n", + " \n", " n = len(a)\n", " for i in range(n):\n", " # bubble up max{a[0..n-i]}:\n", @@ -519,8 +519,7 @@ "\n", "\n", "def index(x,a,n):\n", - " # PRECONDITION: a[0] <= a[1] <= ... <= a[n-1];\n", - " # binary search:\n", + " \n", " lo=0\n", " hi=n-1\n", " while (lo <= hi):\n", @@ -559,7 +558,7 @@ "\n", "\n", "def isNondecreasing(a,n):\n", - " # returns true iff a[0] <= a[1] <= ... <= a[n-1]:\n", + " \n", " for i in range(1,n):\n", " if (a[i]<a[i-1]):\n", " return False\n", @@ -590,7 +589,7 @@ "\n", "\n", "def isNondecreasing(a,n):\n", - " # returns true iff a[0] <= a[1] <= ... <= a[n-1]:\n", + " \n", " for i in range(1,n):\n", " if (a[i]<a[i-1]):\n", " return False\n", |