summaryrefslogtreecommitdiff
path: root/Schaum's_Outlines_-_Programming_with_C++/ch5.ipynb
diff options
context:
space:
mode:
authordebashisdeb2014-06-21 00:52:25 +0530
committerdebashisdeb2014-06-21 00:52:25 +0530
commit7c756fcc12d21693818e58f6936cab5b7c112868 (patch)
tree009cb02ec85f4a75ac7b64239751f15361df2bfe /Schaum's_Outlines_-_Programming_with_C++/ch5.ipynb
parent83c1bfceb1b681b4bb7253b47491be2d8b2014a1 (diff)
downloadPython-Textbook-Companions-7c756fcc12d21693818e58f6936cab5b7c112868.tar.gz
Python-Textbook-Companions-7c756fcc12d21693818e58f6936cab5b7c112868.tar.bz2
Python-Textbook-Companions-7c756fcc12d21693818e58f6936cab5b7c112868.zip
Removed Problem Statements Completely
Diffstat (limited to 'Schaum's_Outlines_-_Programming_with_C++/ch5.ipynb')
-rw-r--r--Schaum's_Outlines_-_Programming_with_C++/ch5.ipynb47
1 files changed, 21 insertions, 26 deletions
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",