summaryrefslogtreecommitdiff
path: root/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)
diff options
context:
space:
mode:
Diffstat (limited to 'Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)')
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/README.txt10
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch1.ipynb381
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch10.ipynb742
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch11.ipynb686
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch12.ipynb757
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch13.ipynb361
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch14.ipynb538
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch15.ipynb1575
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch16.ipynb991
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch2.ipynb623
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch3.ipynb1021
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch4.ipynb1486
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch5.ipynb1542
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch6.ipynb1139
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch7.ipynb629
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch8.ipynb947
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch9.ipynb394
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashu1.pngbin25189 -> 0 bytes
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashu2.pngbin22660 -> 0 bytes
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashu3.pngbin21075 -> 0 bytes
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashutosh-3-1_1.pngbin25189 -> 0 bytes
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashutosh-3-2_1.pngbin22660 -> 0 bytes
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashutosh-3-3_1.pngbin21075 -> 0 bytes
23 files changed, 0 insertions, 13822 deletions
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/README.txt b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/README.txt
deleted file mode 100644
index 3d9a2b47..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/README.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-Contributed By: Ashutosh Kumar
-Course: btech
-College/Institute/Organization: Indian Institute of Technology - Bombay, CHAR Lab 2
-Department/Designation: Electrical Department
-Book Title: Engineering Thermodynamics: A Computer Approach (SI Units Version)
-Author: R. K. Rajput
-Publisher: Laxmi Pulications (P) Ltd., New Delhi
-Year of publication: 2007
-Isbn: 9780763782726
-Edition: 3rd \ No newline at end of file
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch1.ipynb b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch1.ipynb
deleted file mode 100644
index 6d38324f..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch1.ipynb
+++ /dev/null
@@ -1,381 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:2fa8b19d5030cf6dee0c92c2ee4889d5f3659cfd258460db8d8dc9ca2e443363"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "print \"Hello, World!\\n\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Hello, World!\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# prints \"Hello, World!\":\n",
- "print \"Hello, World!\\n\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Hello, World!\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# prints \"Hello, World!\":\n",
- "print \"Hel\" + \"lo, Wo\" + \"rld!\" \n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Hello, World!\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# prints \"Hello, World!\":\n",
- "print \"Hello, W\" + 'o' + \"rld\" + '!' "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Hello, World!\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# prints \"The Millennium ends Dec 31 2000.\":\n",
- "print \"The Millennium ends Dec %d %d \" %(31,2000)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The Millennium ends Dec 31 2000 \n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\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",
- "n = m + 33 # assigns the value 77 to the variable n\n",
- "print \"and n = %d \" % n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "m = 44 and n = 77 \n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# prints \"n = 44:\n",
- "n=44\n",
- "print \"n = %d\" % n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "n = 44\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# Python does not have semicolons so wont give any errors.\n",
- "n=44\n",
- "print \"n = %d\" % n "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "n = 44\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "code",
- "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)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "m = 0 and n = 44\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# defines constants; has no output:\n",
- "BEEP = '\\b'\n",
- "MAXINT = 2147483647\n",
- "N = MAXINT/2\n",
- "KM_PER_MI = 1.60934\n",
- "PI = 3.14159265358979323846\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 10
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# tests the input of integers, floats, and characters:\n",
- "print \"Enter two integers: \"\n",
- "m = int(raw_input())\n",
- "n = int(raw_input())\n",
- "print \"m = %d , n = %d \" %(m,n)\n",
- "\n",
- "print \"Enter three decimal numbers: \"\n",
- "x = float(raw_input())\n",
- "y = float(raw_input())\n",
- "z = float(raw_input())\n",
- "\n",
- "print \"x = %f , y = %f , z = %f\" %(x,y,z)\n",
- "\n",
- "print \"Enter four characters: \";\n",
- "c1 = raw_input()\n",
- "c2 = raw_input()\n",
- "c3 = raw_input()\n",
- "c4 = raw_input()\n",
- "print \"c1 = \" + c1 + \", c2 = \" + c2 + \", c3 = \" + c3 + \", c4 = \" + c4 "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter two integers: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "22\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "44\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "m = 22 , n = 44 \n",
- "Enter three decimal numbers: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "2.2\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "4.4\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "6.6\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "x = 2.200000 , y = 4.400000 , z = 6.600000\n",
- "Enter four characters: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "A\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "B\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "C\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "D\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "c1 = A, c2 = B, c3 = C, c4 = D\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch10.ipynb b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch10.ipynb
deleted file mode 100644
index 11bfc69a..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch10.ipynb
+++ /dev/null
@@ -1,742 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:80ec9afde7f244065f945a9a64c1b3fb1bcbaba0a8461385eab8b48cd3e4fc70"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class Ratio:\n",
- " def __init__(self):\n",
- " self.num = 0\n",
- " self.den = 0\n",
- " def assign(self,n,d):\n",
- " self.num = n\n",
- " self.den = d\n",
- " def convert(self):\n",
- " return float(self.num)/self.den\n",
- " def invert(self):\n",
- " self.num,self.den = self.den,self.num\n",
- " def print_(self):\n",
- " print self.num , '/' , self.den ,\n",
- " \n",
- "x = Ratio()\n",
- "x.assign(22,7)\n",
- "print \"x = \",\n",
- "x.print_()\n",
- "print \" = \" , x.convert() \n",
- "x.invert()\n",
- "print \"1/x = \",\n",
- "x.print_()\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "x = 22 / 7 = 3.14285714286\n",
- "1/x = 7 / 22\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "class Ratio:\n",
- " def __init__(self):\n",
- " self.num = 0\n",
- " self.den = 0\n",
- " def assign(self,n,d):\n",
- " self.num = n\n",
- " self.den = d\n",
- " def convert(self):\n",
- " return float(self.num)/self.den\n",
- " def invert(self):\n",
- " self.num,self.den = self.den,self.num\n",
- " def print_(self):\n",
- " print self.num , '/' , self.den ,\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 2
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class Ratio:\n",
- " def __init__(self,n,d):\n",
- " self.num = n\n",
- " self.den = d\n",
- " def print_(self):\n",
- " print self.num , '/' , self.den ,\n",
- "\n",
- "x = Ratio(-1,3)\n",
- "y = Ratio(22,7)\n",
- "print \"x = \",\n",
- "x.print_()\n",
- "print \" and y = \",\n",
- "y.print_()\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "x = -1 / 3 and y = 22 / 7\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class Ratio:\n",
- " def __init__(self,n=None,d=None):\n",
- " if n==None:\n",
- " self.num = 0\n",
- " self.den = 1\n",
- " elif d==None:\n",
- " self.num = n\n",
- " self.den = 1\n",
- " else:\n",
- " self.num = n\n",
- " self.den = d\n",
- " def print_(self):\n",
- " print self.num , '/' , self.den ,\n",
- "\n",
- "x = Ratio()\n",
- "y = Ratio(4)\n",
- "z = Ratio(22,7)\n",
- "print \"x = \",\n",
- "x.print_()\n",
- "print \"\\ny = \",\n",
- "y.print_()\n",
- "print \"\\nz = \",\n",
- "z.print_()"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "x = 0 / 1 \n",
- "y = 4 / 1 \n",
- "z = 22 / 7\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class Ratio:\n",
- " def __init__(self,n=None,d=None):\n",
- " if n==None:\n",
- " self.num = 0\n",
- " self.den = 1\n",
- " elif d==None:\n",
- " self.num = n\n",
- " self.den = 1\n",
- " else:\n",
- " self.num = n\n",
- " self.den = d\n",
- " def print_(self):\n",
- " print self.num , '/' , self.den ,\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 5
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "class Ratio:\n",
- " def __init__(self,n=0,d=1):\n",
- " self.num = n\n",
- " self.den = d\n",
- " def print_(self):\n",
- " print self.num , '/' , self.den ,\n",
- "\n",
- "\n",
- "x = Ratio()\n",
- "y = Ratio(4)\n",
- "z = Ratio(22,7)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 6
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class Ratio:\n",
- " def __init__(self,n=0,d=1):\n",
- " self.num = n\n",
- " self.den = d\n",
- " def numerator(self):\n",
- " return self.num\n",
- " def denominator(self):\n",
- " return self.den\n",
- " def print_(self):\n",
- " print self.num , '/' , self.den ,\n",
- "\n",
- "\n",
- "x = Ratio(22,7)\n",
- "print x.numerator() , '/' , x.denominator() "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "22 / 7\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def gcd(m,n):\n",
- " # returns the greatest common divisor of m and n:\n",
- " if (m<n):\n",
- " m,n = n,m\n",
- " while (n>0):\n",
- " r = m % n\n",
- " m = n\n",
- " n = r\n",
- " return m\n",
- "\n",
- "class Ratio:\n",
- " def __init__(self,n=0,d=1):\n",
- " self.num = n\n",
- " self.den = d\n",
- " self.reduce()\n",
- " def numerator(self):\n",
- " return self.num\n",
- " def denominator(self):\n",
- " return self.den\n",
- " def print_(self):\n",
- " print self.num , '/' , self.den ,\n",
- "\n",
- " def reduce(self):\n",
- " # enforce invariant(den > 0):\n",
- " if (self.num == 0 or self.den == 0):\n",
- " self.num = 0\n",
- " self.den = 1\n",
- " return\n",
- " if (self.den < 0):\n",
- " self.den *= -1\n",
- " self.num *= -1\n",
- " # enforce invariant(gcd(num,den) == 1):\n",
- " if (self.den == 1):\n",
- " return\n",
- " # it's already reduced\n",
- " sgn = 0\n",
- " if self.num < 0:\n",
- " sgn = -1\n",
- " else:\n",
- " sgn = 1\n",
- " g = gcd(sgn*self.num,self.den)\n",
- " self.num /= g\n",
- " self.den /= g\n",
- "\n",
- "x = Ratio(100,-360)\n",
- "x.print_()\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "-5 / 18\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def gcd(m,n):\n",
- " # returns the greatest common divisor of m and n:\n",
- " if (m<n):\n",
- " m,n = n,m\n",
- " while (n>0):\n",
- " r = m % n\n",
- " m = n\n",
- " n = r\n",
- " return m\n",
- "\n",
- "class Ratio:\n",
- " def __init__(self,n=0,d=None):\n",
- " if d == None:\n",
- " self.num = n.num\n",
- " self.den = n.den\n",
- " else: \n",
- " self.num = n\n",
- " self.den = d\n",
- " self.reduce()\n",
- " def numerator(self):\n",
- " return self.num\n",
- " def denominator(self):\n",
- " return self.den\n",
- " def print_(self):\n",
- " print self.num , '/' , self.den ,\n",
- "\n",
- " def reduce(self):\n",
- " # enforce invariant(den > 0):\n",
- " if (self.num == 0 or self.den == 0):\n",
- " self.num = 0\n",
- " self.den = 1\n",
- " return\n",
- " if (self.den < 0):\n",
- " self.den *= -1\n",
- " self.num *= -1\n",
- " # enforce invariant(gcd(num,den) == 1):\n",
- " if (self.den == 1):\n",
- " return\n",
- " # it's already reduced\n",
- " sgn = 0\n",
- " if self.num < 0:\n",
- " sgn = -1\n",
- " else:\n",
- " sgn = 1\n",
- " g = gcd(sgn*self.num,self.den)\n",
- " self.num /= g\n",
- " self.den /= g\n",
- "\n",
- "x = Ratio(100,360)\n",
- "y = Ratio(x)\n",
- "print \"x = \",\n",
- "x.print_()\n",
- "print \"y = \",\n",
- "y.print_()\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "x = 5 / 18 y = 5 / 18\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def gcd(m,n):\n",
- " # returns the greatest common divisor of m and n:\n",
- " if (m<n):\n",
- " m,n = n,m\n",
- " while (n>0):\n",
- " r = m % n\n",
- " m = n\n",
- " n = r\n",
- " return m\n",
- "\n",
- "class Ratio:\n",
- " def __init__(self,n=0,d=None):\n",
- " if d == None:\n",
- " print \"COPY CONSTRUCTOR CALLED\"\n",
- " self.num = n.num\n",
- " self.den = n.den\n",
- " else: \n",
- " self.num = n\n",
- " self.den = d\n",
- " self.reduce()\n",
- " def numerator(self):\n",
- " return self.num\n",
- " def denominator(self):\n",
- " return self.den\n",
- " def print_(self):\n",
- " print self.num , '/' , self.den ,\n",
- "\n",
- " def reduce(self):\n",
- " # enforce invariant(den > 0):\n",
- " if (self.num == 0 or self.den == 0):\n",
- " self.num = 0\n",
- " self.den = 1\n",
- " return\n",
- " if (self.den < 0):\n",
- " self.den *= -1\n",
- " self.num *= -1\n",
- " # enforce invariant(gcd(num,den) == 1):\n",
- " if (self.den == 1):\n",
- " return\n",
- " # it's already reduced\n",
- " sgn = 0\n",
- " if self.num < 0:\n",
- " sgn = -1\n",
- " else:\n",
- " sgn = 1\n",
- " g = gcd(sgn*self.num,self.den)\n",
- " self.num /= g\n",
- " self.den /= g\n",
- "\n",
- "def f(r):\n",
- " s = Ratio(r)\n",
- "\n",
- "x = Ratio(22,7)\n",
- "y = Ratio(x) #calls the copy constructor, copying x to y\n",
- "f(y)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "COPY CONSTRUCTOR CALLED\n",
- "COPY CONSTRUCTOR CALLED\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class Ratio:\n",
- " def __init__(self):\n",
- " print \"OBJECT IS BORN.\"\n",
- " def __del__(self):\n",
- " print \"OBJECT DIES.\"\n",
- "\n",
- "x = Ratio()\n",
- "print \"Now x is alive.\"\n",
- "print \"Now between blocks.\"\n",
- "y = Ratio()\n",
- "print \"Now y is alive.\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "OBJECT IS BORN.\n",
- "Now x is alive.\n",
- "Now between blocks.\n",
- "OBJECT IS BORN.\n",
- "Now y is alive.\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class X:\n",
- " def __init(self):\n",
- " data = 0\n",
- "\n",
- "p = X()\n",
- "p.data = 22\n",
- "print \"p.data = \" , p.data , \" = \" , p.data\n",
- "p.data = 44\n",
- "print \" p.data = \" , p.data , \" = \" , p.data "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "p.data = 22 = 22\n",
- " p.data = 44 = 44\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class Node:\n",
- " def __init__(self,d,q=None):\n",
- " self.data = d\n",
- " self.next = q\n",
- "\n",
- "n = int(raw_input())\n",
- "q = Node(n)\n",
- "while True:\n",
- " n = int(raw_input())\n",
- " if n<=0:\n",
- " break\n",
- " p = Node(n, q)\n",
- " q = p\n",
- "k = p\n",
- "while k != None:\n",
- " print k.data , '->' , \n",
- " k = k.next\n",
- "print '*'\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "22\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "33\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "44\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "55\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "66\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "77\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "77 -> 66 -> 55 -> 44 -> 33 -> 22 -> *\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "count = 0\n",
- "class Widget:\n",
- " def __init__(self):\n",
- " global count\n",
- " count += 1\n",
- " \n",
- "w = Widget()\n",
- "x = Widget()\n",
- "print \"Now there are \" , count , 'widgets'\n",
- "if True:\n",
- " w = Widget()\n",
- " x = Widget()\n",
- " y = Widget()\n",
- " z = Widget()\n",
- " print \"Now there are\" , count , 'widgets' \n",
- "print \"Now there are \" , count , 'widgets'\n",
- "y = Widget()\n",
- "print \"Now there are \" , count , 'widgets'\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "OBJECT DIES.\n",
- "Now there are 2 widgets\n",
- "OBJECT DIES.\n",
- "Now there are 6 widgets\n",
- "Now there are 6 widgets\n",
- "Now there are 7 widgets\n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "count = 0\n",
- "class Widget:\n",
- " def __init__(self):\n",
- " global count\n",
- " count += 1\n",
- " def numWidgets(self):\n",
- " global count\n",
- " return count\n",
- " \n",
- "w = Widget()\n",
- "x = Widget()\n",
- "print \"Now there are \" , w.numWidgets() , 'widgets'\n",
- "if True:\n",
- " w = Widget()\n",
- " x = Widget()\n",
- " y = Widget()\n",
- " z = Widget()\n",
- " print \"Now there are\" , w.numWidgets() , 'widgets' \n",
- "print \"Now there are \" , w.numWidgets() , 'widgets'\n",
- "y = Widget()\n",
- "print \"Now there are \" , w.numWidgets() , 'widgets'\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Now there are 2 widgets\n",
- "Now there are 6 widgets\n",
- "Now there are 6 widgets\n",
- "Now there are 7 widgets\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "count = 0\n",
- "class Widget:\n",
- " def __init__(self):\n",
- " global count\n",
- " count += 1\n",
- " def numWidgets(self):\n",
- " global count\n",
- " return count\n",
- " \n",
- "w = Widget()\n",
- "x = Widget()\n",
- "print \"Now there are \" , w.numWidgets() , 'widgets'\n",
- "if True:\n",
- " w = Widget()\n",
- " x = Widget()\n",
- " y = Widget()\n",
- " z = Widget()\n",
- " print \"Now there are\" , w.numWidgets() , 'widgets' \n",
- "print \"Now there are \" , w.numWidgets() , 'widgets'\n",
- "y = Widget()\n",
- "print \"Now there are \" , w.numWidgets() , 'widgets'"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Now there are 2 widgets\n",
- "Now there are 6 widgets\n",
- "Now there are 6 widgets\n",
- "Now there are 7 widgets\n"
- ]
- }
- ],
- "prompt_number": 18
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch11.ipynb b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch11.ipynb
deleted file mode 100644
index 34fb61dc..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch11.ipynb
+++ /dev/null
@@ -1,686 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:bdd5f9e441ccb7e3a87f4d8c5492d0aa1d228caba299fc1b0c667abb12780a1e"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class Ratio:\n",
- " def __init__(self,n=None,d=None):\n",
- " if d==None:\n",
- " self.num = n.num\n",
- " self.den = n.den\n",
- " elif n==None:\n",
- " self.num = 0\n",
- " self.den = 1\n",
- " else:\n",
- " self.num = n\n",
- " self.den = d\n",
- " \n",
- " def equals(self):\n",
- " return self # retuns calling object."
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 1
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class Ratio:\n",
- " def __init__(self,n=None,d=None):\n",
- " pass\n",
- " \n",
- " def equals(self):\n",
- " pass\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 2
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class Ratio:\n",
- " def __init__(self,n=None,d=None):\n",
- " if d==None:\n",
- " self.num = n.num\n",
- " self.den = n.den\n",
- " elif n==None:\n",
- " self.num = 0\n",
- " self.den = 1\n",
- " else:\n",
- " self.num = n\n",
- " self.den = d\n",
- " \n",
- "\n",
- "z = Ratio(22,7)\n",
- "y = z\n",
- "x = z\n",
- "\n",
- "x = Ratio(22,7)\n",
- "y = Ratio(x)\n",
- "z = x\n",
- "w = x"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 3
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "class Ratio:\n",
- " def __init__(self,n=None,d=None):\n",
- " self.num = n\n",
- " self.den = d\n",
- " def __mul__(self,y):\n",
- " pass\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 4
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def gcd(m,n):\n",
- " # returns the greatest common divisor of m and n:\n",
- " if (m<n):\n",
- " m,n = n,m\n",
- " while (n>0):\n",
- " r = m % n\n",
- " m = n\n",
- " n = r\n",
- " return m\n",
- "\n",
- "\n",
- "class Ratio:\n",
- " def __init__(self,n=None,d=None):\n",
- " self.num = n\n",
- " self.den = d\n",
- " self.reduce()\n",
- " def __mul__(self,y):\n",
- " z = Ratio(self.num * y.num, self.den * y.den)\n",
- " return z\n",
- " def print_(self):\n",
- " print self.num , '/', self.den\n",
- " \n",
- " def reduce(self):\n",
- " # enforce invariant(den > 0):\n",
- " if (self.num == 0 or self.den == 0):\n",
- " self.num = 0\n",
- " self.den = 1\n",
- " return\n",
- " if (self.den < 0):\n",
- " self.den *= -1\n",
- " self.num *= -1\n",
- " # enforce invariant(gcd(num,den) == 1):\n",
- " if (self.den == 1):\n",
- " return\n",
- " # it's already reduced\n",
- " sgn = 0\n",
- " if self.num < 0:\n",
- " sgn = -1\n",
- " else:\n",
- " sgn = 1\n",
- " g = gcd(sgn*self.num,self.den)\n",
- " self.num /= g\n",
- " self.den /= g\n",
- "x = Ratio(22,7)\n",
- "y = Ratio(-3,8)\n",
- "z = x\n",
- "z.print_()\n",
- "x = y*z\n",
- "x.print_()\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "22 / 7\n",
- "-33 / 28\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def gcd(m,n):\n",
- " # returns the greatest common divisor of m and n:\n",
- " if (m<n):\n",
- " m,n = n,m\n",
- " while (n>0):\n",
- " r = m % n\n",
- " m = n\n",
- " n = r\n",
- " return m\n",
- "\n",
- "\n",
- "class Ratio:\n",
- " def __init__(self,n=None,d=None):\n",
- " self.num = n\n",
- " self.den = d\n",
- " self.reduce()\n",
- " def __imul__(self,y):\n",
- " self.num = self.num * y.num\n",
- " self.den = self.den * y.den\n",
- " def print_(self):\n",
- " print self.num , '/', self.den"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 6
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "class Ratio:\n",
- " def __init__(self,n=None,d=None):\n",
- " self.num = n\n",
- " self.den = d\n",
- " self.reduce()\n",
- " def __imul__(self,y):\n",
- " self.num = self.num * y.num\n",
- " self.den = self.den * y.den\n",
- " def __eq__(self,y):\n",
- " return (x.num * y.den == y.num * x.den)\n",
- " def print_(self):\n",
- " print self.num , '/', self.den\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 7
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "class Ratio:\n",
- " def __init__(self,n=None,d=None):\n",
- " self.num = n\n",
- " self.den = d\n",
- " def __imul__(self,y):\n",
- " self.num = self.num * y.num\n",
- " self.den = self.den * y.den\n",
- " def __eq__(self,y):\n",
- " return (x.num * y.den == y.num * x.den)\n",
- " def print_(self):\n",
- " print self.num , '/', self.den\n",
- "\n",
- "\n",
- "x = Ratio(22,7)\n",
- "y = Ratio(-3,8)\n",
- "x.print_() , y.print_()\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "22 / 7\n",
- "-3 / 8\n"
- ]
- },
- {
- "metadata": {},
- "output_type": "pyout",
- "prompt_number": 8,
- "text": [
- "(None, None)"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def gcd(m,n):\n",
- " # returns the greatest common divisor of m and n:\n",
- " if (m<n):\n",
- " m,n = n,m\n",
- " while (n>0):\n",
- " r = m % n\n",
- " m = n\n",
- " n = r\n",
- " return m\n",
- "class Ratio:\n",
- " def __init__(self,n=0,d=1):\n",
- " self.num = n\n",
- " self.den = d\n",
- " self.reduce()\n",
- " def __mul__(self,y):\n",
- " z = Ratio(self.num * y.num, self.den * y.den)\n",
- " return z\n",
- " def print_(self):\n",
- " print self.num , '/', self.den\n",
- " \n",
- " def input(self):\n",
- " self.num = int(raw_input('Numerator : '))\n",
- " self.den = int(raw_input('Denominator : '))\n",
- " self.reduce()\n",
- " def reduce(self):\n",
- " # enforce invariant(den > 0):\n",
- " if (self.num == 0 or self.den == 0):\n",
- " self.num = 0\n",
- " self.den = 1\n",
- " return\n",
- " if (self.den < 0):\n",
- " self.den *= -1\n",
- " self.num *= -1\n",
- " # enforce invariant(gcd(num,den) == 1):\n",
- " if (self.den == 1):\n",
- " return\n",
- " # it's already reduced\n",
- " sgn = 0\n",
- " if self.num < 0:\n",
- " sgn = -1\n",
- " else:\n",
- " sgn = 1\n",
- " g = gcd(sgn*self.num,self.den)\n",
- " self.num /= g\n",
- " self.den /= g\n",
- "\n",
- "\n",
- "x = Ratio()\n",
- "y = Ratio()\n",
- "x.input()\n",
- "y.input()\n",
- "x.print_()\n",
- "y.print_()\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Numerator : -10\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Denominator : -24\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Numerator : 36\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Denominator : -20\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "5 / 12\n",
- "-9 / 5\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def gcd(m,n):\n",
- " # returns the greatest common divisor of m and n:\n",
- " if (m<n):\n",
- " m,n = n,m\n",
- " while (n>0):\n",
- " r = m % n\n",
- " m = n\n",
- " n = r\n",
- " return m\n",
- "class Ratio:\n",
- " def __init__(self,n=0,d=1):\n",
- " self.num = n\n",
- " self.den = d\n",
- " self.reduce()\n",
- " def __mul__(self,y):\n",
- " z = Ratio(self.num * y.num, self.den * y.den)\n",
- " return z\n",
- " def print_(self):\n",
- " print self.num , '/', self.den\n",
- " \n",
- " def input(self):\n",
- " self.num = int(raw_input('Numerator : '))\n",
- " self.den = int(raw_input('Denominator : '))\n",
- " self.reduce()\n",
- " def __float__(self):\n",
- " return float(self.num)/self.den\n",
- " def reduce(self):\n",
- " # enforce invariant(den > 0):\n",
- " if (self.num == 0 or self.den == 0):\n",
- " self.num = 0\n",
- " self.den = 1\n",
- " return\n",
- " if (self.den < 0):\n",
- " self.den *= -1\n",
- " self.num *= -1\n",
- " # enforce invariant(gcd(num,den) == 1):\n",
- " if (self.den == 1):\n",
- " return\n",
- " # it's already reduced\n",
- " sgn = 0\n",
- " if self.num < 0:\n",
- " sgn = -1\n",
- " else:\n",
- " sgn = 15.py\n",
- " g = gcd(sgn*self.num,self.den)\n",
- " self.num /= g\n",
- " self.den /= g\n",
- "\n",
- "x = Ratio(-5,8)\n",
- "print \"x = \" , \n",
- "x.print_() \n",
- "print \", float(x) = \" , float(x) \n",
- "P = Ratio(22,7)\n",
- "PI = float(P)\n",
- "print \"P = \" ,\n",
- "P.print_() \n",
- "print \", PI = \" , PI\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "x = -5 / 8\n",
- ", float(x) = -0.625\n",
- "P = 22 / 7\n",
- ", PI = 3.14285714286\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def gcd(m,n):\n",
- " # returns the greatest common divisor of m and n:\n",
- " if (m<n):\n",
- " m,n = n,m\n",
- " while (n>0):\n",
- " r = m % n\n",
- " m = n\n",
- " n = r\n",
- " return m\n",
- "class Ratio:\n",
- " def __init__(self,n=0,d=1):\n",
- " self.num = n\n",
- " self.den = d\n",
- " self.reduce()\n",
- " def __mul__(self,y):\n",
- " z = Ratio(self.num * y.num, self.den * y.den)\n",
- " return z\n",
- " def print_(self):\n",
- " print self.num , '/', self.den\n",
- " \n",
- " def __iadd__(self,n):\n",
- " self.num += self.den\n",
- " return self\n",
- " def reduce(self):\n",
- " # enforce invariant(den > 0):\n",
- " if (self.num == 0 or self.den == 0):\n",
- " self.num = 0\n",
- " self.den = 1\n",
- " return\n",
- " if (self.den < 0):\n",
- " self.den *= -1\n",
- " self.num *= -1\n",
- " # enforce invariant(gcd(num,den) == 1):\n",
- " if (self.den == 1):\n",
- " return\n",
- " # it's already reduced\n",
- " sgn = 0\n",
- " if self.num < 0:\n",
- " sgn = -1\n",
- " else:\n",
- " sgn = 1\n",
- " g = gcd(sgn*self.num,self.den)\n",
- " self.num /= g\n",
- " self.den /= g\n",
- "\n",
- "x = Ratio(22,7)\n",
- "x += 1\n",
- "y = x\n",
- "print \"y = \" ,\n",
- "y.print_()\n",
- "print \", x = \",\n",
- "x.print_()\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "y = 29 / 7\n",
- ", x = 29 / 7\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def gcd(m,n):\n",
- " # returns the greatest common divisor of m and n:\n",
- " if (m<n):\n",
- " m,n = n,m\n",
- " while (n>0):\n",
- " r = m % n\n",
- " m = n\n",
- " n = r\n",
- " return m\n",
- "class Ratio:\n",
- " def __init__(self,n=0,d=1):\n",
- " self.num = n\n",
- " self.den = d\n",
- " self.reduce()\n",
- " def __mul__(self,y):\n",
- " z = Ratio(self.num * y.num, self.den * y.den)\n",
- " return z\n",
- " def print_(self):\n",
- " print self.num , '/', self.den\n",
- " \n",
- " def __iadd__(self,n):\n",
- " self.num += self.den\n",
- " return self\n",
- " def reduce(self):\n",
- " # enforce invariant(den > 0):\n",
- " if (self.num == 0 or self.den == 0):\n",
- " self.num = 0\n",
- " self.den = 1\n",
- " return\n",
- " if (self.den < 0):\n",
- " self.den *= -1\n",
- " self.num *= -1\n",
- " # enforce invariant(gcd(num,den) == 1):\n",
- " if (self.den == 1):\n",
- " return\n",
- " # it's already reduced\n",
- " sgn = 0\n",
- " if self.num < 0:\n",
- " sgn = -1\n",
- " else:\n",
- " sgn = 1\n",
- " g = gcd(sgn*self.num,self.den)\n",
- " self.num /= g\n",
- " self.den /= g\n",
- "\n",
- "x = Ratio(22,7)\n",
- "y = Ratio(x.num,x.den)\n",
- "x += 1\n",
- "print \"y = \" ,\n",
- "y.print_()\n",
- "print \", x = \",\n",
- "x.print_()\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "y = 22 / 7\n",
- ", x = 29 / 7\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def gcd(m,n):\n",
- " # returns the greatest common divisor of m and n:\n",
- " if (m<n):\n",
- " m,n = n,m\n",
- " while (n>0):\n",
- " r = m % n\n",
- " m = n\n",
- " n = r\n",
- " return m\n",
- "class Ratio:\n",
- " def __init__(self,n=0,d=1):\n",
- " self.num = n\n",
- " self.den = d\n",
- " self.reduce()\n",
- " def __mul__(self,y):\n",
- " z = Ratio(self.num * y.num, self.den * y.den)\n",
- " return z\n",
- " def print_(self):\n",
- " print self.num , '/', self.den\n",
- " \n",
- " def __getitem__(self,k):\n",
- " if k == 1:\n",
- " return self.num\n",
- " else:\n",
- " return self.den\n",
- " def reduce(self):\n",
- " # enforce invariant(den > 0):\n",
- " if (self.num == 0 or self.den == 0):\n",
- " self.num = 0\n",
- " self.den = 1\n",
- " return\n",
- " if (self.den < 0):\n",
- " self.den *= -1\n",
- " self.num *= -1\n",
- " # enforce invariant(gcd(num,den) == 1):\n",
- " if (self.den == 1):\n",
- " return\n",
- " # it's already reduced\n",
- " sgn = 0\n",
- " if self.num < 0:\n",
- " sgn = -1\n",
- " else:\n",
- " sgn = 1\n",
- " g = gcd(sgn*self.num,self.den)\n",
- " self.num /= g\n",
- " self.den /= g\n",
- "\n",
- "x = Ratio(22,7)\n",
- "print \"x = \" ,\n",
- "x.print_()\n",
- "print \"x[1] = \" , x[1] , \", x[2] = \" , x[2]\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "x = 22 / 7\n",
- "x[1] = 22 , x[2] = 7\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch12.ipynb b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch12.ipynb
deleted file mode 100644
index 2fc62abb..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch12.ipynb
+++ /dev/null
@@ -1,757 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:f377691760a60edd5db7fbe78ee867c7be9afd9802ecd81bd9e073874d13c99c"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class Person:\n",
- " def __init__(self,n=\"\",nat=\"U.S.A.\",s=1):\n",
- " self.name = n\n",
- " self.nationality = nat\n",
- " self.sex = s\n",
- "\n",
- " def printName(self):\n",
- " print self.name,\n",
- " \n",
- " def printNationality(self):\n",
- " print self.nationality,\n",
- "\n",
- "creator = Person(\"Bjarne Stroustrup\", \"Denmark\")\n",
- "print \"The creator of C++ was \" ,\n",
- "creator.printName() \n",
- "print \", who was born in \" ,\n",
- "creator.printNationality() \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The creator of C++ was Bjarne Stroustrup , who was born in Denmark\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "class Date:\n",
- " def __init__(self,m=0,d=0,y=0):\n",
- " self.month = m\n",
- " self.day = d\n",
- " self.year = y\n",
- " \n",
- " def setDate(self,m,d,y):\n",
- " self.month = m\n",
- " self.day = d\n",
- " self.year = y\n",
- " # Python doesn't have >> operator for input so we are just using input function\n",
- " def input(self):\n",
- " self.month = int(raw_input()) \n",
- " self.day = int(raw_input())\n",
- " self.year = int(raw_input()) \n",
- " \n",
- " # Python doesn't have << operator for output so we are just using print function\n",
- " def print_(self):\n",
- " monthName = [\"\", \"January\",\"February\",\"March\", \"April\", \"May\", \"June\",\\\n",
- " \"July\", \"August\",\"September\", \"October\", \"November\",\\\n",
- " \"December\"]\n",
- " print monthName[self.month] , self.day , \",\" , self.year\n",
- "\n",
- "peace = Date(11,11,1918)\n",
- "print \"World War I ended on \" ,\n",
- "peace.print_()\n",
- "peace.setDate(8,14,1945)\n",
- "print \"World War II ended on \" ,\n",
- "peace.print_()\n",
- "print \"Enter month, day, and year: \"\n",
- "date = Date()\n",
- "date.input()\n",
- "print \"The date is \" , \n",
- "date.print_()\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "World War I ended on November 11 , 1918\n",
- "World War II ended on August 14 , 1945\n",
- "Enter month, day, and year: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "7\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "4\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "1976\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The date is July 4 , 1976\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class Date:\n",
- " def __init__(self,m=0,d=0,y=0):\n",
- " self.month = m\n",
- " self.day = d\n",
- " self.year = y\n",
- " \n",
- " def setDate(self,m,d,y):\n",
- " self.month = m\n",
- " self.day = d\n",
- " self.year = y\n",
- " # Python doesn't have >> operator for input so we are just using input function\n",
- " def input(self):\n",
- " self.month = int(raw_input()) \n",
- " self.day = int(raw_input())\n",
- " self.year = int(raw_input()) \n",
- " \n",
- " # Python doesn't have << operator for output so we are just using print function\n",
- " def print_(self):\n",
- " monthName = [\"\", \"January\",\"February\",\"March\", \"April\", \"May\", \"June\",\\\n",
- " \"July\", \"August\",\"September\", \"October\", \"November\",\\\n",
- " \"December\"]\n",
- " print monthName[self.month] , self.day , \",\" , self.year\n",
- "\n",
- "class Person:\n",
- " def __init__(self,n=\"\",s=0,nat=\"U.S.A.\"):\n",
- " self.name = n\n",
- " self.nationality = nat\n",
- " self.sex = s\n",
- " self.dob = Date()\n",
- " self.dod = Date()\n",
- " def setDOB(self,m,d,y):\n",
- " self.dob.setDate(m,d,y)\n",
- " def setDOD(self,m,d,y):\n",
- " self.dod.setDate(m,d,y)\n",
- " def printName(self):\n",
- " print self.name,\n",
- " def printNationality(self):\n",
- " print self.nationality,\n",
- " def printDOB(self):\n",
- " self.dob.print_()\n",
- " def printDOD(self):\n",
- " self.dod.print_()\n",
- "\n",
- "author = Person(\"Thomas Jefferson\", 1)\n",
- "author.setDOB(4,13,1743)\n",
- "author.setDOD(7,4,1826)\n",
- "print \"The author of the Declaration of Independence was \",\n",
- "author.printName()\n",
- "print \".\\nHe was born on \",\n",
- "author.printDOB()\n",
- "print \" and died on \",\n",
- "author.printDOD()\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The author of the Declaration of Independence was Thomas Jefferson .\n",
- "He was born on April 13 , 1743\n",
- " and died on July 4 , 1826\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class Date:\n",
- " def __init__(self,m=0,d=0,y=0):\n",
- " self.month = m\n",
- " self.day = d\n",
- " self.year = y\n",
- " \n",
- " def setDate(self,m,d,y):\n",
- " self.month = m\n",
- " self.day = d\n",
- " self.year = y\n",
- " # Python doesn't have >> operator for input so we are just using input function\n",
- " def input(self):\n",
- " self.month = int(raw_input()) \n",
- " self.day = int(raw_input())\n",
- " self.year = int(raw_input()) \n",
- " \n",
- " # Python doesn't have << operator for output so we are just using print function\n",
- " def print_(self):\n",
- " monthName = [\"\", \"January\",\"February\",\"March\", \"April\", \"May\", \"June\",\\\n",
- " \"July\", \"August\",\"September\", \"October\", \"November\",\\\n",
- " \"December\"]\n",
- " print monthName[self.month] , self.day , \",\" , self.year\n",
- "\n",
- "class Person:\n",
- " def __init__(self,n=\"\",s=0,nat=\"U.S.A.\"):\n",
- " self.name = n\n",
- " self.nationality = nat\n",
- " self.sex = s\n",
- " self.dob = Date()\n",
- " self.dod = Date()\n",
- " def setDOB(self,m,d,y):\n",
- " self.dob.setDate(m,d,y)\n",
- " def setDOD(self,m,d,y):\n",
- " self.dod.setDate(m,d,y)\n",
- " def printName(self):\n",
- " print self.name,\n",
- " def printNationality(self):\n",
- " print self.nationality,\n",
- " def printDOB(self):\n",
- " self.dob.print_()\n",
- " def printDOD(self):\n",
- " self.dod.print_()\n",
- "\n",
- "class Student(Person):\n",
- " def __init__(self,n,s=0,i=\"\"):\n",
- " Person.__init__(self,n,s)\n",
- " self.id = i\n",
- " self.credits = 0\n",
- " self.gpa = 0\n",
- " self.dom = Date()\n",
- "\n",
- " def setDOM(self,m,d,y):\n",
- " self.dom.setDate(m, d, y)\n",
- " def printDOM(self):\n",
- " self.dom.print_()\n",
- "\n",
- "x = Student(\"Ann Jones\", 0, \"219360061\")\n",
- "x.setDOB(5, 13, 1977)\n",
- "x.setDOM(8, 29, 1995)\n",
- "x.printName()\n",
- "print \"\\n\\t Born: \" ,\n",
- "x.printDOB()\n",
- "print \"\\n\\tMatriculated: \",\n",
- "x.printDOM()\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Ann Jones \n",
- "\t Born: May 13 , 1977\n",
- "\n",
- "\tMatriculated: August 29 , 1995\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class Date:\n",
- " def __init__(self,m=0,d=0,y=0):\n",
- " self.month = m\n",
- " self.day = d\n",
- " self.year = y\n",
- " \n",
- " def setDate(self,m,d,y):\n",
- " self.month = m\n",
- " self.day = d\n",
- " self.year = y\n",
- " # Python doesn't have >> operator for input so we are just using input function\n",
- " def input(self):\n",
- " self.month = int(raw_input()) \n",
- " self.day = int(raw_input())\n",
- " self.year = int(raw_input()) \n",
- " \n",
- " # Python doesn't have << operator for output so we are just using print function\n",
- " def print_(self):\n",
- " monthName = [\"\", \"January\",\"February\",\"March\", \"April\", \"May\", \"June\",\\\n",
- " \"July\", \"August\",\"September\", \"October\", \"November\",\\\n",
- " \"December\"]\n",
- " print monthName[self.month] , self.day , \",\" , self.year\n",
- "\n",
- "class Person:\n",
- " def __init__(self,n=\"\",s=0,nat=\"U.S.A.\"):\n",
- " self.name = n\n",
- " self.nationality = nat\n",
- " self.sex = s\n",
- " self.dob = Date()\n",
- " self.dod = Date()\n",
- " def setDOB(self,m,d,y):\n",
- " self.dob.setDate(m,d,y)\n",
- " def setDOD(self,m,d,y):\n",
- " self.dod.setDate(m,d,y)\n",
- " def printName(self):\n",
- " print self.name,\n",
- " def printNationality(self):\n",
- " print self.nationality,\n",
- " def printDOB(self):\n",
- " self.dob.print_()\n",
- " def printDOD(self):\n",
- " self.dod.print_()\n",
- "\n",
- "class Student(Person):\n",
- " def __init__(self,n,s=0,i=\"\"):\n",
- " Person.__init__(self,n,s)\n",
- " self.id = i\n",
- " self.credits = 0\n",
- " self.gpa = 0\n",
- " self.dom = Date()\n",
- "\n",
- " def setDOM(self,m,d,y):\n",
- " self.dom.setDate(m, d, y)\n",
- " def printDOM(self):\n",
- " self.dom.print_()\n",
- " def printSex(self):\n",
- " if self.sex == 1:\n",
- " print \"male\"\n",
- " else:\n",
- " print 'female'\n",
- "\n",
- "x = Student(\"Ann Jones\", 0, \"219360061\")\n",
- "x.setDOB(5, 13, 1977)\n",
- "x.setDOM(8, 29, 1995)\n",
- "x.setDOD(7,4,1826)\n",
- "x.printName()\n",
- "print \"\\n\\t Born: \" , \n",
- "x.printDOB()\n",
- "print \"\\n\\t Sex: \" ,\n",
- "x.printSex()\n",
- "print \"\\n\\tMatriculated: \",\n",
- "x.printDOM()\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Ann Jones \n",
- "\t Born: May 13 , 1977\n",
- "\n",
- "\t Sex: female\n",
- "\n",
- "\tMatriculated: August 29 , 1995\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class X:\n",
- " def __init__(self):\n",
- " self.a = 0\n",
- " def f(self):\n",
- " print \"X::f() executing\"\n",
- "class Y(X):\n",
- " def __init__(self):\n",
- " self.a = 0\n",
- " def f(self):\n",
- " print \"Y::f() executing\"\n",
- "x = X()\n",
- "x.a = 22\n",
- "x.f()\n",
- "print \"x.a = \" , x.a\n",
- "y = Y()\n",
- "y.a = 44\n",
- "# assigns 44 to the a defined in Y\n",
- "y._X__a = 66\n",
- "# assigns 66 to the a defined in X\n",
- "y.f()\n",
- "# invokes the f() defined in Y\n",
- "X.f(x)\n",
- "# invokes the f() defined in X\n",
- "print \"y.a = \" , y.a \n",
- "print \"y._X__a = \" , y._X__a \n",
- "z = y\n",
- "print \"z.a = \" , z._X__a \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "X::f() executing\n",
- "x.a = 22\n",
- "Y::f() executing\n",
- "X::f() executing\n",
- "y.a = 44\n",
- "y._X__a = 66\n",
- "z.a = 66\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class X:\n",
- " def __init__(self):\n",
- " print \"X::X() constructor executing \"\n",
- " def __del__(self):\n",
- " print \"X::X() destructor executing \"\n",
- "\n",
- "class Y(X):\n",
- " def __init__(self):\n",
- " X.__init__(self)\n",
- " print \"Y::Y() constructor executing \"\n",
- " def __del__(self):\n",
- " print \"Y::Y() destructor executing \"\n",
- "\n",
- "class Z(Y):\n",
- " def __init__(self,i):\n",
- " Y.__init__(self)\n",
- " print \"Z::Z(\" , i , \") constructor executing \"\n",
- " def __del__(self):\n",
- " print \"Z::Z() destructor executing \"\n",
- " \n",
- "\n",
- "Z = Z(44)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "X::X() constructor executing \n",
- "Y::Y() constructor executing \n",
- "Z::Z( 44 ) constructor executing \n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class Person:\n",
- " def __init__(self,s):\n",
- " self.name = s\n",
- " def __del__(self):\n",
- " pass\n",
- "\n",
- "class Student(Person):\n",
- " def __init__(self,s,m):\n",
- " Person.__init__(self,s)\n",
- " self.major = m\n",
- " def __del__(self):\n",
- " pass\n",
- "x = Person(\"Bob\")\n",
- "y = Student(\"Sarah\", \"Biology\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 8
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "class Person:\n",
- " def __init__(self,n=\"\",s=0,nat=\"U.S.A.\"):\n",
- " self.name = n\n",
- " self.nationality = nat\n",
- " self.sex = s\n",
- " self.dob = Date()\n",
- " self.dod = Date()\n",
- " def setDOB(self,m,d,y):\n",
- " self.dob.setDate(m,d,y)\n",
- " def setDOD(self,m,d,y):\n",
- " self.dod.setDate(m,d,y)\n",
- " def printName(self):\n",
- " print self.name,\n",
- " def printNationality(self):\n",
- " print self.nationality,\n",
- " def printDOB(self):\n",
- " self.dob.print_()\n",
- " def printDOD(self):\n",
- " self.dod.print_()\n",
- " def setHSgraduate(self,g):\n",
- " self.hs = g\n",
- " def isHSgraduate(self):\n",
- " return hs\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 9
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class X:\n",
- " def f(self):\n",
- " print \"X::f() executing\"\n",
- "class Y(X):\n",
- " def f(self):\n",
- " print \"Y::f() executing\"\n",
- "x = X()\n",
- "y = Y()\n",
- "p = x\n",
- "p.f()\n",
- "p = y\n",
- "p.f()\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "X::f() executing\n",
- "Y::f() executing\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class Person:\n",
- " def __init__(self,n):\n",
- " self.name = n\n",
- " def print_(self):\n",
- " print 'My name is' , self.name\n",
- "\n",
- "class Student(Person):\n",
- " def __init__(self,s,g):\n",
- " Person.__init__(self,s)\n",
- " self.gpa = g\n",
- " def print_(self):\n",
- " print 'My name is ',self.name, ' and my G.P.A. is', self.gpa\n",
- "\n",
- "class Professor(Person):\n",
- " def __init__(self,s,n):\n",
- " Person.__init__(self,s)\n",
- " self.publs = n\n",
- " def print_(self):\n",
- " print 'My name is ', self.name,' and i have ' , self.publs,' publications.'\n",
- "\n",
- "x = Person(\"Bob\")\n",
- "p = x\n",
- "p.print_()\n",
- "y = Student(\"Tom\", 3.47)\n",
- "p = y\n",
- "p.print_()\n",
- "z = Professor(\"Ann\", 7)\n",
- "p = z\n",
- "p.print_()"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "My name is Bob\n",
- "My name is Tom and my G.P.A. is 3.47\n",
- "My name is Ann and i have 7 publications.\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class X:\n",
- " def __init__(self):\n",
- " self.p = [0,0]\n",
- " print 'X().',\n",
- " def __del__(self):\n",
- " print '~X().'\n",
- "\n",
- "class Y(X):\n",
- " def __init__(self):\n",
- " X.__init__(self)\n",
- " self.q = []\n",
- " for i in range(1023):\n",
- " self.q.append(0)\n",
- " print 'Y() : Y::q = ', hex(id(self.q)) ,'.',\n",
- " def __del__(self):\n",
- " print '~Y().'\n",
- "\n",
- "for i in range(8):\n",
- " r = Y()"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "X(). Y() : Y::q = 0x90d91cc . ~Y().\n",
- "X(). Y() : Y::q = 0x90c944c . ~Y().\n",
- "X(). Y() : Y::q = 0x90d91cc . ~Y().\n",
- "X(). Y() : Y::q = 0x90c944c . ~Y().\n",
- "X(). Y() : Y::q = 0x90d91cc . ~Y().\n",
- "X(). Y() : Y::q = 0x90c944c . ~Y().\n",
- "X(). Y() : Y::q = 0x90d91cc . ~Y().\n",
- "X(). Y() : Y::q = 0x90c944c . ~Y().\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class Media:\n",
- " def __init__(self):\n",
- " self.title = ''\n",
- " def print_(self):\n",
- " pass\n",
- " def id(self):\n",
- " pass\n",
- "\n",
- "class Book(Media):\n",
- " def __init__(self,a='',t=\"\",p=\"\",i=\"\"):\n",
- " self.author = a\n",
- " self.publisher = p\n",
- " self.isbn = i\n",
- " self.title = t\n",
- " def print_(self):\n",
- " print self.title , \" by \" , self.author\n",
- " def id(self):\n",
- " return self.isbn\n",
- "\n",
- "class CD(Media):\n",
- " def __init__(self,t=\"\",c=\"\",m=\"\",n=\"\"):\n",
- " self.composer = c\n",
- " self.make = m\n",
- " self.number = n\n",
- " self.title = t\n",
- " def print_(self):\n",
- " print self.title , \", \" , self.composer\n",
- " def id(self):\n",
- " s = str(self.make) + ' ' + str(self.number)\n",
- " return s\n",
- "\n",
- "class Magazine(Media):\n",
- " def __init__(self,t=\"\",i=\"\",v=0, n=0):\n",
- " self.issn = i\n",
- " self.volume = v\n",
- " self.number = n\n",
- " self.title = t\n",
- " def print_(self):\n",
- " print self.title , \" Magazine, Vol. \", self.volume , \", No.\" , self.number\n",
- " def id(self):\n",
- " return self.issn\n",
- "\n",
- "book = Book(\"Bjarne Stroustrup\", \"The C++ Programming Language\",\"Addison-Wesley\", \"0-201-53992-6\")\n",
- "magazine = Magazine(\"TIME\", \"0040-781X\", 145, 23)\n",
- "cd = CD(\"BACH CANTATAS\", \"Johann Sebastian Bach\",\"ARCHIV\", \"D120541\")\n",
- "book.print_()\n",
- "print \"\\tid: \" , book.id() \n",
- "magazine.print_()\n",
- "print \"\\tid: \" , magazine.id() \n",
- "cd.print_()\n",
- "print \"\\tid: \" , cd.id()"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The C++ Programming Language by Bjarne Stroustrup\n",
- "\tid: 0-201-53992-6\n",
- "TIME Magazine, Vol. 145 , No. 23\n",
- "\tid: 0040-781X\n",
- "BACH CANTATAS , Johann Sebastian Bach\n",
- "\tid: ARCHIV D120541\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch13.ipynb b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch13.ipynb
deleted file mode 100644
index 5261a124..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch13.ipynb
+++ /dev/null
@@ -1,361 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:ca23888d127466a3b56ff597f51112b17faee9e92f25f41708b3d49e2ac19a08"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def swap(x,y):\n",
- " x[0],y[0] = y[0],x[0]\n",
- "\n",
- "m = [22]\n",
- "n = [66]\n",
- "swap(m, n)\n",
- "s1 = [\"John Adams\"]\n",
- "s2 = [\"James Madison\"]\n",
- "swap(s1, s2)\n",
- "x = [22/7]\n",
- "y = [-3]\n",
- "swap(x, y)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 1
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def sort(v,n):\n",
- " for i in range(1,n):\n",
- " for j in range(n-i):\n",
- " if v[j] > v[j+1]:\n",
- " v[j],v[j+1] = v[j+1],v[j]\n",
- "\n",
- "def print_( v,n):\n",
- " for i in range(n):\n",
- " print v[i],\n",
- " print \"\"\n",
- " \n",
- "a = [55, 33, 88, 11, 44, 99, 77, 22, 66]\n",
- "print_(a,9);\n",
- "sort(a,9)\n",
- "print_(a,9)\n",
- "s = [\"Tom\", \"Hal\", \"Dan\", \"Bob\", \"Sue\", \"Ann\", \"Gus\"]\n",
- "print_(s,7)\n",
- "sort(s,7)\n",
- "print_(s,7)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "55 33 88 11 44 99 77 22 66 \n",
- "11 22 33 44 55 66 77 88 99 \n",
- "Tom Hal Dan Bob Sue Ann Gus \n",
- "Ann Bob Dan Gus Hal Sue Tom \n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class Stack:\n",
- " def __init__(self,s=100):\n",
- " self.size = s\n",
- " self.top = -1\n",
- " self.data = []\n",
- " def push(self,x):\n",
- " self.data.append( x)\n",
- " self.top += 1\n",
- " def pop(self):\n",
- " d = self.data[self.top]\n",
- " self.data.pop(self.top)\n",
- " self.top -= 1\n",
- " return d \n",
- " def isEmpty(self):\n",
- " return self.top == -1\n",
- " def isFull(self):\n",
- " return self.top==self.size-1\n",
- " \n",
- "intStack1 = Stack(5)\n",
- "intStack2 = Stack(10)\n",
- "charStack = Stack(8)\n",
- "intStack1.push(77)\n",
- "charStack.push('A')\n",
- "intStack2.push(22)\n",
- "charStack.push('E')\n",
- "charStack.push('K')\n",
- "intStack2.push(44)\n",
- "print intStack2.pop() \n",
- "print intStack2.pop() \n",
- "if (intStack2.isEmpty()):\n",
- " print \"intStack2 is empty.\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "44\n",
- "22\n",
- "intStack2 is empty.\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class Vector:\n",
- " def __init__(self,n=None):\n",
- " if type(n) == int :\n",
- " self.size = n\n",
- " self.data = []\n",
- " else:\n",
- " self.size = 8\n",
- " self.data = []\n",
- " for i in range(self.size):\n",
- " self.data.append(0)\n",
- "v = Vector()\n",
- "v.data[5] = 127\n",
- "w = v\n",
- "x = Vector(3)\n",
- "print w.size\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "8\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "class Vector:\n",
- " def __init__(self,n=None):\n",
- " if type(n) == int :\n",
- " self.size = n\n",
- " self.data = []\n",
- " else:\n",
- " self.size = 8\n",
- " self.data = []\n",
- " for i in range(self.size):\n",
- " self.data.append(0)\n",
- "\n",
- "class Array(Vector):\n",
- " def __init__(self,i,j):\n",
- " Vector.__init__(self,j-i+1)\n",
- " self.i0= i\n",
- " def __setitem__(self,k,v):\n",
- " self.data[k-self.i0] = v\n",
- " def __getitem__(self,i):\n",
- " return self.data[self.i0-i]\n",
- " def firstSubscript(self):\n",
- " return self.i0\n",
- " def lastSubscript(self):\n",
- " return self.i0+self.size-1\n",
- "\n",
- "x = Array(1,3)\n",
- "x.data[0] = 3.14159\n",
- "x.data[1] = 0.08516\n",
- "x.data[2] = 5041.92\n",
- "print \"x.size() = \" , x.size \n",
- "print \"x.firstSubscript() = \" , x.firstSubscript() \n",
- "print \"x.lastSubscript() = \" , x.lastSubscript()\n",
- "for i in range(0,3):\n",
- " print \"x[\" , i + 1 , \"] = \" , x.data[i]\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "x.size() = 3\n",
- "x.firstSubscript() = 1\n",
- "x.lastSubscript() = 3\n",
- "x[ 1 ] = 3.14159\n",
- "x[ 2 ] = 0.08516\n",
- "x[ 3 ] = 5041.92\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "class Matrix:\n",
- " def __init__(self,r=1,c=1):\n",
- " self.rows = r\n",
- " self.columns = c\n",
- " self.vector = []\n",
- " for i in range(r):\n",
- " a = []\n",
- " for j in range(c):\n",
- " a.append(0)\n",
- " self.vector.append(a)\n",
- "\n",
- "a = Matrix(2,3)\n",
- "a.vector[0][0] = 0.0\n",
- "a.vector[0][1] = 0.1\n",
- "a.vector[0][2] = 0.2\n",
- "a.vector[1][0] = 1.0\n",
- "a.vector[1][1] = 1.1\n",
- "a.vector[1][2] = 1.2\n",
- "\n",
- "print \"The matrix a has \" , a.rows , \" rows and \", a.columns , \" columns:\"\n",
- "for i in range(2):\n",
- " for j in range(3):\n",
- " print a.vector[i][j] ,\n",
- " print \"\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The matrix a has 2 rows and 3 columns:\n",
- "0.0 0.1 0.2 \n",
- "1.0 1.1 1.2 \n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "friends = []\n",
- "\n",
- "\n",
- "friends.insert(0,\"Bowen, Van\")\n",
- "friends.insert(0,\"Dixon, Tom\")\n",
- "friends.insert(0,\"Mason, Joe\")\n",
- "friends.insert(0,\"White, Ann\")\n",
- "\n",
- "for i in range(len(friends)):\n",
- " print friends[i], '->' ,\n",
- "print '*'\n",
- "friends.remove('White, Ann')\n",
- "print \"Removed: \" , 'White, Ann'\n",
- "for i in range(len(friends)):\n",
- " print friends[i], '->' ,\n",
- "print '*'\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "White, Ann -> Mason, Joe -> Dixon, Tom -> Bowen, Van -> *\n",
- "Removed: White, Ann\n",
- "Mason, Joe -> Dixon, Tom -> Bowen, Van -> *\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "friends = []\n",
- "friends.append(\"Bowen, Van\")\n",
- "friends.append(\"Dixon, Tom\")\n",
- "friends.append(\"Mason, Joe\")\n",
- "friends.append(\"White, Ann\")\n",
- "for i in range(len(friends)):\n",
- " print friends[i], '->' ,\n",
- "print '*'\n",
- "\n",
- "friends.remove(\"Mason, Joe\")\n",
- "friends[1] = \"Davis, Jim\"\n",
- "for i in range(len(friends)):\n",
- " print friends[i], '->' ,\n",
- "print '*'\n",
- "\n",
- "friends.insert(2,\"Morse, Sam\")\n",
- "for i in range(len(friends)):\n",
- " print friends[i], '->' ,\n",
- "print '*'\n",
- "\n",
- "for i in range(len(friends)):\n",
- " print \"[\" ,friends[i] , \"]\" , '->' ,\n",
- "print '*'\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Bowen, Van -> Dixon, Tom -> Mason, Joe -> White, Ann -> *\n",
- "Bowen, Van -> Davis, Jim -> White, Ann -> *\n",
- "Bowen, Van -> Davis, Jim -> Morse, Sam -> White, Ann -> *\n",
- "[ Bowen, Van ] -> [ Davis, Jim ] -> [ Morse, Sam ] -> [ White, Ann ] -> *\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch14.ipynb b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch14.ipynb
deleted file mode 100644
index 6d15626d..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch14.ipynb
+++ /dev/null
@@ -1,538 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:81aae5e06fff42b82bf693bbb18c1546fd839925af34574cc2f25fff08c2a482"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def load(v):\n",
- " v.append(\"Japan\")\n",
- " v.append(\"Italy\")\n",
- " v.append(\"Spain\")\n",
- " v.append(\"Egypt\")\n",
- " v.append(\"Chile\")\n",
- " v.append(\"Zaire\")\n",
- " v.append(\"Nepal\")\n",
- " v.append(\"Kenya\")\n",
- "\n",
- "def print_(v):\n",
- " for i in v:\n",
- " print i\n",
- "\n",
- "v = []\n",
- "load(v)\n",
- "print_(v)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Japan\n",
- "Italy\n",
- "Spain\n",
- "Egypt\n",
- "Chile\n",
- "Zaire\n",
- "Nepal\n",
- "Kenya\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def load(v):\n",
- " v.append(\"Japan\")\n",
- " v.append(\"Italy\")\n",
- " v.append(\"Spain\")\n",
- " v.append(\"Egypt\")\n",
- " v.append(\"Chile\")\n",
- " v.append(\"Zaire\")\n",
- " v.append(\"Nepal\")\n",
- " v.append(\"Kenya\")\n",
- "\n",
- "def print_(v):\n",
- " for i in v:\n",
- " print i\n",
- "\n",
- "v = []\n",
- "load(v)\n",
- "print_(v)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Japan\n",
- "Italy\n",
- "Spain\n",
- "Egypt\n",
- "Chile\n",
- "Zaire\n",
- "Nepal\n",
- "Kenya\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def load(v):\n",
- " v.append(\"Japan\")\n",
- " v.append(\"Italy\")\n",
- " v.append(\"Spain\")\n",
- " v.append(\"Egypt\")\n",
- " v.append(\"Chile\")\n",
- " v.append(\"Zaire\")\n",
- " v.append(\"Nepal\")\n",
- " v.append(\"Kenya\")\n",
- "\n",
- "def print_(v):\n",
- " for i in range(len(v)):\n",
- " print v[i]\n",
- "\n",
- "v = []\n",
- "load(v)\n",
- "print_(v)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Japan\n",
- "Italy\n",
- "Spain\n",
- "Egypt\n",
- "Chile\n",
- "Zaire\n",
- "Nepal\n",
- "Kenya\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def load(v):\n",
- " v.append(\"Japan\")\n",
- " v.append(\"Italy\")\n",
- " v.append(\"Spain\")\n",
- " v.append(\"Egypt\")\n",
- " v.append(\"Chile\")\n",
- " v.append(\"Zaire\")\n",
- " v.append(\"Nepal\")\n",
- " v.append(\"Kenya\")\n",
- "\n",
- "def print_(v):\n",
- " for i in v:\n",
- " print i\n",
- "\n",
- "v = []\n",
- "load(v)\n",
- "v.sort()\n",
- "print_(v)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Chile\n",
- "Egypt\n",
- "Italy\n",
- "Japan\n",
- "Kenya\n",
- "Nepal\n",
- "Spain\n",
- "Zaire\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def load(v):\n",
- " v.append(\"Japan\")\n",
- " v.append(\"Italy\")\n",
- " v.append(\"Spain\")\n",
- " v.append(\"Egypt\")\n",
- " v.append(\"Chile\")\n",
- " v.append(\"Zaire\")\n",
- " v.append(\"Nepal\")\n",
- " v.append(\"Kenya\")\n",
- "\n",
- "def print_(v):\n",
- " for i in v:\n",
- " print i\n",
- "\n",
- "v = []\n",
- "load(v)\n",
- "w = v\n",
- "print_(v)\n",
- "print_(w)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Japan\n",
- "Italy\n",
- "Spain\n",
- "Egypt\n",
- "Chile\n",
- "Zaire\n",
- "Nepal\n",
- "Kenya\n",
- "Japan\n",
- "Italy\n",
- "Spain\n",
- "Egypt\n",
- "Chile\n",
- "Zaire\n",
- "Nepal\n",
- "Kenya\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def load(v):\n",
- " v.append(\"Japan\")\n",
- " v.append(\"Italy\")\n",
- " v.append(\"Spain\")\n",
- " v.append(\"Egypt\")\n",
- " v.append(\"Chile\")\n",
- " v.append(\"Zaire\")\n",
- " v.append(\"Nepal\")\n",
- " v.append(\"Kenya\")\n",
- "\n",
- "def print_(v):\n",
- " for i in v:\n",
- " print i\n",
- "\n",
- "v = []\n",
- "load(v)\n",
- "v.sort()\n",
- "print_(v)\n",
- "print \"v.front() = \" + v[0]\n",
- "print \"v.back() = \" + v.pop(-1) \n",
- "print \"v.back() = \" + v.pop(-1) \n",
- "print \"v.back() = \" + v[-1] \n",
- "print_(v)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Chile\n",
- "Egypt\n",
- "Italy\n",
- "Japan\n",
- "Kenya\n",
- "Nepal\n",
- "Spain\n",
- "Zaire\n",
- "v.front() = Chile\n",
- "v.back() = Zaire\n",
- "v.back() = Spain\n",
- "v.back() = Nepal\n",
- "Chile\n",
- "Egypt\n",
- "Italy\n",
- "Japan\n",
- "Kenya\n",
- "Nepal\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def load(v):\n",
- " v.append(\"Japan\")\n",
- " v.append(\"Italy\")\n",
- " v.append(\"Spain\")\n",
- " v.append(\"Egypt\")\n",
- " v.append(\"Chile\")\n",
- " v.append(\"Zaire\")\n",
- " v.append(\"Nepal\")\n",
- " v.append(\"Kenya\")\n",
- "\n",
- "def print_(v):\n",
- " for i in v:\n",
- " print i\n",
- "\n",
- "v = []\n",
- "load(v)\n",
- "v.sort()\n",
- "print_(v)\n",
- "v.pop(2) # removes Italy\n",
- "v.pop(-2) # removes Spain\n",
- "print_(v)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Chile\n",
- "Egypt\n",
- "Italy\n",
- "Japan\n",
- "Kenya\n",
- "Nepal\n",
- "Spain\n",
- "Zaire\n",
- "Chile\n",
- "Egypt\n",
- "Japan\n",
- "Kenya\n",
- "Nepal\n",
- "Zaire\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def load(v):\n",
- " v.append(\"Japan\")\n",
- " v.append(\"Italy\")\n",
- " v.append(\"Spain\")\n",
- " v.append(\"Egypt\")\n",
- " v.append(\"Chile\")\n",
- " v.append(\"Zaire\")\n",
- " v.append(\"Nepal\")\n",
- " v.append(\"Kenya\")\n",
- "\n",
- "def print_(v):\n",
- " for i in v:\n",
- " print i\n",
- "v = []\n",
- "load(v)\n",
- "v.sort()\n",
- "print_(v)\n",
- "r = []\n",
- "for i in range(2,len(v)-2):\n",
- " r.append(v[i]) #removes the segment Italy..Nepal\n",
- " \n",
- "for i in r:\n",
- " v.remove(i)\n",
- "print_(v)\n",
- "v.insert(2,\"India\")\n",
- "print_(v)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Chile\n",
- "Egypt\n",
- "Italy\n",
- "Japan\n",
- "Kenya\n",
- "Nepal\n",
- "Spain\n",
- "Zaire\n",
- "Chile\n",
- "Egypt\n",
- "Spain\n",
- "Zaire\n",
- "Chile\n",
- "Egypt\n",
- "India\n",
- "Spain\n",
- "Zaire\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def load(v):\n",
- " v.append(\"Japan\")\n",
- " v.append(\"Italy\")\n",
- " v.append(\"Spain\")\n",
- " v.append(\"Egypt\")\n",
- " v.append(\"Chile\")\n",
- " v.append(\"Zaire\")\n",
- " v.append(\"Nepal\")\n",
- " v.append(\"Kenya\")\n",
- " v.append(\"India\")\n",
- " v.append(\"China\")\n",
- " v.append(\"Malta\")\n",
- " v.append(\"Syria\")\n",
- "\n",
- "def print_(v):\n",
- " for i in v:\n",
- " print i\n",
- "\n",
- "v = []\n",
- "load(v)\n",
- "print_(v)\n",
- "egypt = v.index('Egypt')\n",
- "malta = v.index('Malta')\n",
- "w = v[egypt:malta+1]\n",
- "w.sort()\n",
- "print_(w)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Japan\n",
- "Italy\n",
- "Spain\n",
- "Egypt\n",
- "Chile\n",
- "Zaire\n",
- "Nepal\n",
- "Kenya\n",
- "India\n",
- "China\n",
- "Malta\n",
- "Syria\n",
- "Chile\n",
- "China\n",
- "Egypt\n",
- "India\n",
- "Kenya\n",
- "Malta\n",
- "Nepal\n",
- "Zaire\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def copy(v,x,n):\n",
- " for i in x:\n",
- " v.append(i)\n",
- "\n",
- "def projection(v,b):\n",
- " v_size = len(v)\n",
- " w = []\n",
- " for i in range(0,v_size):\n",
- " if b[i]:\n",
- " w.append(v[i])\n",
- " return w\n",
- "\n",
- "def print_(v):\n",
- " for i in v:\n",
- " print i,\n",
- " print ''\n",
- "\n",
- "x = [ 22.2, 33.3, 44.4, 55.5, 66.6, 77.7, 88.8, 99.9 ]\n",
- "v = []\n",
- "copy(v, x, 8)\n",
- "y = [ False, True, False, True, True, True, False, True ]\n",
- "b = []\n",
- "copy(b, y, 8)\n",
- "w = projection(v, b)\n",
- "print_(v)\n",
- "print_(w)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "22.2 33.3 44.4 55.5 66.6 77.7 88.8 99.9 \n",
- "33.3 55.5 66.6 77.7 99.9 \n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch15.ipynb b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch15.ipynb
deleted file mode 100644
index 869f8b29..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch15.ipynb
+++ /dev/null
@@ -1,1575 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:63b02b86d37296507c195a23c5c84302645481c443c7f5e7bd4fa711e72942f7"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 15 : Heat Transfer"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.1 page no : 792"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# Variables\n",
- "t1 = 60.; \t\t\t#0C\n",
- "t2 = 35.; \t\t\t#0C\n",
- "L = 0.22; \t\t\t#m\n",
- "k = 0.51; \t\t\t#W/m 0C\n",
- "\n",
- "# Calculations\n",
- "q = k*(t1-t2)/L;\n",
- "\n",
- "# Results\n",
- "print (\"Rate of heat transfer per m**2 = %.3f\")% (q), (\"W/m**2\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Rate of heat transfer per m**2 = 57.955 W/m**2\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.2 page no : 792"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# Variables\n",
- "t1 = 1325.; \t\t\t#0C\n",
- "t2 = 1200.; \t\t\t#0C\n",
- "t3 = 25.; \t\t\t #0C\n",
- "L = 0.32; \t\t\t #m\n",
- "k_A = 0.84; \t\t\t#W/m 0C\n",
- "k_B = 0.16; \t\t\t#W/m 0C\n",
- "\n",
- "# Calculations and Results\n",
- "L_A = (t1-t2)*k_A/k_B*L/((t1-t3)-(t1-t2)*k_A/k_A+(t1-t2)*k_A/k_B); \t\t\t#m\n",
- "print (\"(i)L_A = %.3f\")% (L_A*1000), (\"mm\")\n",
- "\n",
- "L_B = 0.32-L_A; \t\t\t#m\n",
- "print (\"L_B %.3f\")% (L_B*1000), (\"mm\")\n",
- "\n",
- "q = (t1-t2)/L_A*k_A;\n",
- "print (\"(ii) Heat loss per unit area = %.3f\")% (q), (\"W/m**2\")\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "(i)L_A = 114.676 mm\n",
- "L_B 205.324 mm\n",
- "(ii) Heat loss per unit area = 915.625 W/m**2\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.3 page no : 793"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# Variables\n",
- "L_A = 0.1; \t\t\t#m\n",
- "L_B = 0.04; \t\t#m\n",
- "k_A = 0.7; \t\t\t#W/m 0C\n",
- "k_B = 0.48; \t\t#W/m 0C\n",
- "k_C = 0.065; \t\t#W/m 0C\n",
- "\n",
- "# Calculations\n",
- "#Q2 = 0.2*Q1\n",
- "L_C = 0.8*((L_A/k_A) + (L_B/k_B))*k_C/0.2;\n",
- "\n",
- "# Results\n",
- "print (\"thickness of rock wool insulation = %.3f\")% (L_C*1000), (\"mm\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "thickness of rock wool insulation = 58.810 mm\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.4 page no : 794"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "# Variables\n",
- "L_A = 0.2; \t\t\t#m\n",
- "L_C = 0.006; \t\t#m\n",
- "L_D = 0.1; \t\t\t#m\n",
- "t1 = 1150.; \t\t#0C\n",
- "t2 = 40.; \t\t\t#0C\n",
- "dt = t1-t2;\n",
- "k_A = 1.52; \t\t#W/m 0C\n",
- "k_B = 0.138; \t\t#W/m 0C\n",
- "k_D = 0.138; \t\t#W/m 0C\n",
- "k_C = 45.; \t\t\t#W/m 0C\n",
- "q = 400.; \t\t\t#W/m**2\n",
- "\n",
- "# Calculations and Results\n",
- "print (\"(i) The value of x = (L_C): \")\n",
- "L_B = ((t1-t2)/q - (L_A/k_A+L_C/k_C+L_D/k_D))*k_B*1000;\n",
- "print (\"L_B = %.3f\")% (L_B), (\"mm\")\n",
- "\n",
- "\n",
- "t_so = q*L_D/k_D + t2;\n",
- "print (\"(ii) Temperature of the outer surface of the steel plate t_so = %.3f\")% (t_so), (\"0C\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "(i) The value of x = (L_C): \n",
- "L_B = 264.774 mm\n",
- "(ii) Temperature of the outer surface of the steel plate t_so = 329.855 0C\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.5 page no : 795"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# Variables\n",
- "k_A = 150.; \t\t\t#W/m 0C\n",
- "k_B = 30.; \t\t\t#W/m 0C\n",
- "k_C = 65.; \t\t\t#W/m 0C\n",
- "k_D = 50.; \t\t\t#W/m 0C\n",
- "L_A = 0.03; \t\t\t#m\n",
- "L_B = 0.08; \t\t\t#m\n",
- "L_C = L_B;\n",
- "L_D = 0.05; \t\t\t#m\n",
- "A_A = 0.01; \t\t\t#m**2\n",
- "A_B = 0.003; \t\t\t#m**2\n",
- "A_C = 0.007; \t\t\t#m**2\n",
- "A_D = 0.01; \t\t\t#m**2\n",
- "t1 = 400.; \t\t\t#0C\n",
- "t4 = 60.; \t\t\t#0C\n",
- "\n",
- "# Calculations\n",
- "R_thA = L_A/k_A/A_A;\n",
- "R_thB = L_B/k_B/A_B;\n",
- "R_thC = L_C/k_C/A_C;\n",
- "R_thD = L_D/k_D/A_D;\n",
- "\n",
- "R_th_eq = R_thB*R_thC/(R_thB+R_thC);\n",
- "R_th_total = R_thA+R_th_eq+R_thD;\n",
- "Q = (t1-t4)/R_th_total;\n",
- "\n",
- "# Results\n",
- "print (\"heat flow rate = %.3f\")% (Q), (\"W\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "heat flow rate = 1274.415 W\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.6 page no : 796"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# Variables\n",
- "L = 0.012; \t\t\t#m\n",
- "t_hf = 95.; \t\t\t#0C\n",
- "t_cf = 15.; \t\t\t#0C\n",
- "k = 50.; \t\t\t#W/m 0C\n",
- "h_hf = 2850.; \t\t\t#W/m**2 0C\n",
- "h_cf = 10.; \t\t\t#W/m**2 0C\n",
- "\n",
- "# Calculations and Results\n",
- "print (\"(i) Rate of heat loss per m**2 of the tank surface area\")\n",
- "U = 1./(1./h_hf + L/k + 1./h_cf);\n",
- "A = 1.; \t\t\t #m**2\n",
- "q = U*A*(t_hf-t_cf);\n",
- "print (\"q = %.3f\")% (q), (\"W/m**2\")\n",
- "\n",
- "t2 = q/h_cf+t_cf;\n",
- "print (\"(ii) Temperature of the outside surface of the tank = %.3f\")% (t2), (\"0C\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "(i) Rate of heat loss per m**2 of the tank surface area\n",
- "q = 795.301 W/m**2\n",
- "(ii) Temperature of the outside surface of the tank = 94.530 0C\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.7 page no : 797"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "# Variables\n",
- "L_A = 0.003; \t\t\t#m\n",
- "L_B = 0.05; \t\t\t#m\n",
- "L_C = L_A;\n",
- "k_A = 46.5; \t\t\t#W/m 0C\n",
- "k_B = 0.046; \t\t\t#W/m 0C\n",
- "k_C = k_A;\n",
- "h0 = 11.6; \t\t\t#W/m**2 0C\n",
- "hi = 14.5; \t\t\t#W/m**2 0C\n",
- "t0 = 25.; \t\t\t#0C\n",
- "ti = 6.; \t\t\t#0C\n",
- "\n",
- "# Calculations and Results\n",
- "A = 0.5*0.5*2+0.5*1*4; \t\t\t#m**2\n",
- "\n",
- "Q = A*(t0-ti)/(1/h0 + L_A/k_A + L_B/k_B + L_C/k_C + 1/hi);\n",
- "print (\"(i) The rate of removal of heat = %.3f\")% (Q), (\"W\")\n",
- "\n",
- "t1 = t0-Q/h0/A;\n",
- "print (\"(ii) The temperature at the outer surface of the metal sheet = %.3f\")% (t1), (\"0C\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "(i) The rate of removal of heat = 38.237 W\n",
- "(ii) The temperature at the outer surface of the metal sheet = 23.681 0C\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.8 page no : 798"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "#Varaible Declaration\n",
- "L_A = 0.25; \t\t#m\n",
- "import math \n",
- "L_B = 0.1; \t\t\t#m\n",
- "L_C = 0.15; \t\t#m\n",
- "k_A = 1.65; \t\t#W/m \u00b0C\n",
- "k_C = 9.2; \t\t\t#W/m \u00b0C\n",
- "t_hf = 1250.; \t\t#\u00b0C\n",
- "t1 = 1100.; \t\t\t#\u00b0C\n",
- "t_cf = 25.; \t\t\t#\u00b0C\n",
- "h_hf = 25.; \t\t\t#W/m**2 \u00b0C\n",
- "h_cf = 12.; \t\t\t#W/m**2 \u00b0C\n",
- "\n",
- "\n",
- "#Calculations and Results\n",
- "q = h_hf*(t_hf-t1);\n",
- "l = 0.0355\n",
- "k_B = L_B/l #((t_hf-t_cf)/q-1/h_hf-L_A/k_A-L_C/k_C-1/h_cf);\n",
- "print (\" (i)Thermal conductivity,k = %.3f\")% (k_B), (\"W/m**2 \u00b0C\")\n",
- "\n",
- "\n",
- "R_th_total = 1./h_hf+L_A/k_A+L_B/k_B+L_C/k_C+1./h_cf;\n",
- "U = 1/R_th_total\n",
- "print (\"(ii) The overall transfer coefficient = %.2f\")% (U), (\"W/m**2 \u00b0C\")\n",
- "\n",
- "\n",
- "print (\"(iii) All surface temperature \")\n",
- "\n",
- "print (\"t1 = %.3f\")% (t1),(\"\u00b0C\")\n",
- "\n",
- "t2 = t1-q*L_A/k_A;\n",
- "print (\"t2 = %.3f\")% (t2), (\"\u00b0C\")\n",
- "\n",
- "t3 = t2-q*L_B/k_B;\n",
- "print (\"t3 = %.3f\")% (t3), (\"\u00b0C\")\n",
- "\n",
- "t4 = t3-q*L_C/k_C;\n",
- "print (\"t4 = %.3f\")% (t4), (\"\u00b0C\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " (i)Thermal conductivity,k = 2.817 W/m**2 \u00b0C\n",
- "(ii) The overall transfer coefficient = 3.06 W/m**2 \u00b0C\n",
- "(iii) All surface temperature \n",
- "t1 = 1100.000 \u00b0C\n",
- "t2 = 531.818 \u00b0C\n",
- "t3 = 398.693 \u00b0C\n",
- "t4 = 337.552 \u00b0C\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.9 page no : 802"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math\n",
- "\n",
- "# Variables\n",
- "r1 = 0.01; \t\t\t#m\n",
- "r2 = 0.02; \t\t\t#m\n",
- "r3 = 0.05; \t\t\t#m\n",
- "t1 = 600.; \t\t\t#0C\n",
- "t3 = 1000.; \t\t#0C\n",
- "k_B = 0.2; \t\t\t#W/m 0C\n",
- "\n",
- "# Calculations\n",
- "q = 2*math.pi*(t1-t3)/(math.log(r3/r2)/k_B);\n",
- "\n",
- "# Results\n",
- "print (\"Heat transfer per metre of length = %.3f\")% (q), (\"W/m\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Heat transfer per metre of length = -548.576 W/m\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.10 page no : 803"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math\n",
- "\n",
- "# Variables\n",
- "r1 = 0.06; \t\t\t#m\n",
- "r2 = 0.12; \t\t\t#m\n",
- "r3 = 0.16; \t\t\t#m\n",
- "k_A = 0.24; \t\t\t#W/m 0C\n",
- "k_B = 0.4; \t\t\t#W/m 0C\n",
- "h_hf = 60.; \t\t\t#W/m**2 0C\n",
- "h_cf = 12.; \t\t\t#W/m**2 0C\n",
- "t_hf = 65.; \t\t\t#0C\n",
- "t_cf = 20.; \t\t\t#0C\n",
- "L = 60.; \t\t\t#m\n",
- "\n",
- "# Calculations\n",
- "Q = 2*math.pi*L*(t_hf-t_cf)/(1/h_hf/r1 + math.log(r2/r1)/k_A + math.log(r3/r2)/k_B + 1/h_cf/r3);\n",
- "\n",
- "# Results\n",
- "print (\"Rate of heat loss = %.3f\")% (Q), (\"W\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Rate of heat loss = 3850.402 W\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.11 page no : 804"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "r1 = 0.06; \t\t\t#m\n",
- "r2 = 0.08; \t\t\t#m\n",
- "k_A = 42.; \t\t\t#W/m 0C\n",
- "k_B = 0.8; \t\t\t#W/m 0C\n",
- "t_hf = 150.; \t\t\t#0C\n",
- "t_cf = 20.; \t\t\t#0C\n",
- "h_hf = 100.; \t\t\t#W/m**2 0C\n",
- "h_cf = 30.; \t\t\t#W/m**2 0C\n",
- "r3 = 0.105; \t\t\t#m\n",
- "\n",
- "# Calculations\n",
- "thickness = (r3-r2)*1000; \t\t\t#mm\n",
- "\n",
- "# Results\n",
- "print (\"Thickness of insulation = \"), (thickness), (\"mm\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Thickness of insulation = 25.0 mm\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.12 page no : 807"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "# Variables\n",
- "r2 = 0.7; \t\t\t#m\n",
- "r1 = 0.61; \t\t\t#m\n",
- "dt = 220.; \t\t\t#dt = t1-t2; 0C\n",
- "k = 0.083; \t\t\t#W/m 0C\n",
- "\n",
- "# Calculations\n",
- "Q = dt/((r2-r1)/(4*math.pi*k*r1*r2));\n",
- "\n",
- "# Results\n",
- "print (\"Rate of heat leakage = %.3f\")% (Q), (\"W\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Rate of heat leakage = 1088.669 W\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.13 page no : 811"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "r1 = 0.001; \t\t\t#m\n",
- "r2 = 0.0018; \t\t\t#m\n",
- "k = 0.12; \t\t\t#W/m 0C\n",
- "h0 = 35.; \t\t\t#W/m**2 0C\n",
- "\n",
- "# Calculations\n",
- "rc = k/h0;\n",
- "thickness = (rc-r1)*10**3; \t\t\t#mm\n",
- "increase = (1/(math.log(rc/r1)/k + 1/h0/rc)-1/(math.log(r2/r1)/k + 1/h0/r2))/(1/(math.log(r2/r1)/k + 1/h0/r2))*100;\n",
- "\n",
- "# Results\n",
- "print (\"Critical thickness of insulation = %.3f\")% (thickness), (\"mm\")\n",
- "\n",
- "print (\"Percentage change in heat transfer rate = %.3f\")% (increase), (\"%\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Critical thickness of insulation = 2.429 mm\n",
- "Percentage change in heat transfer rate = 11.666 %\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.14 page no : 813"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "# Variables\n",
- "A = 1*1.5; \t\t\t#m**2\n",
- "ts = 300.; \t\t\t#0C\n",
- "tf = 20.; \t\t\t#0C\n",
- "h = 20.; \t\t\t#W/m**2 0C\n",
- "\n",
- "# Calculations\n",
- "Q = h*A*(ts-tf)/10**3; \t\t\t#kW\n",
- "\n",
- "# Results\n",
- "print (\"Rate of heat transfer = \"), (Q), (\"kW\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Rate of heat transfer = 8.4 kW\n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.15 page no : 813"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math\n",
- "\n",
- "# Variables\n",
- "d = 0.0015; \t\t\t#m\n",
- "l = 0.15; \t\t\t#m\n",
- "A = math.pi*d*l;\n",
- "ts = 120.; \t\t\t#0C\n",
- "tf = 100.; \t\t\t#0C\n",
- "h = 4500.; \t\t\t#W/m**2 0C\n",
- "\n",
- "# Calculations\n",
- "Q = h*A*(ts-tf);\n",
- "\n",
- "# Results\n",
- "print (\"Electric power to be supplied = %.3f\")% (Q), (\"W\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Electric power to be supplied = 63.617 W\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.16 page no : 814"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "D = 0.045; \t\t\t#m\n",
- "l = 3.2; \t\t\t#m\n",
- "u = 0.78; \t\t\t#m/s\n",
- "k = 0.66; \t\t\t#W/m K\n",
- "v = 0.478*10**(-6); \t\t\t#m**2/s\n",
- "Pr = 2.98;\n",
- "tw = 70.; \t\t\t#0C\n",
- "tf = 50.; \t\t\t#0C\n",
- "\n",
- "# Calculations\n",
- "A = math.pi*D*l;\n",
- "Re = D*u/v;\n",
- "h = 0.023*(Re)**0.8*(Pr)**0.4/D*k;\n",
- "Q = h*A*(tw-tf)/10**3;\n",
- "\n",
- "# Results\n",
- "print (\"Heat transfer co-efficient = %.3f\")% (h), (\"W/m**2 K\")\n",
- "\n",
- "print (\"Rate of heat transfer = %.3f\")% (Q), (\"kW\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Heat transfer co-efficient = 4078.018 W/m**2 K\n",
- "Rate of heat transfer = 36.897 kW\n"
- ]
- }
- ],
- "prompt_number": 18
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.17 page no : 814"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "rho = 983.2; \t\t\t#kg/m**2\n",
- "cp = 4.187; \t\t\t#kJ/kg K\n",
- "k = 0.659; \t\t\t#W/m 0C\n",
- "v = 0.478*10**(-6); \t\t\t#m**2/s\n",
- "m = 0.5/60; \t\t\t#kg/s\n",
- "D = 0.02; \t\t\t#m\n",
- "ti = 20.; \t\t\t#0C\n",
- "t0 = 50.; \t\t\t#0C\n",
- "ts = 85.; \t\t\t#surface temperature in 0C\n",
- "\n",
- "# Calculations\n",
- "tf = 1./2*(ts+(ti+t0)/2);\n",
- "A = math.pi/4*D**2;\n",
- "u = m/rho/A;\n",
- "Re = D*u/v;\n",
- "\n",
- "#Since Re < 2000, hence the flow is laminar.\n",
- "Nu = 3.65;\n",
- "h = Nu*k/D;\n",
- "tb = (t0+ti)/2;\n",
- "L = m*cp*10**3*(t0-ti)/(ts-tb)/h/D/math.pi;\n",
- "\n",
- "# Results\n",
- "print (\"Length of the tube required for fully developed flow = %.3f\")% (L), (\"m\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Length of the tube required for fully developed flow = 2.770 m\n"
- ]
- }
- ],
- "prompt_number": 19
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.18 page no : 825"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "m_h = 0.2; \t\t\t#kg/s\n",
- "m_c = 0.5; \t\t\t#kg/s\n",
- "t_h1 = 75.; \t\t\t#0C\n",
- "t_h2 = 45.; \t\t\t#0C\n",
- "t_c1 = 20.; \t\t\t#0C\n",
- "hi = 650.; \t\t\t#W/m**2 0C\n",
- "h0 = hi;\n",
- "cph = 4.187;\n",
- "cpc = cph\n",
- "\n",
- "# Calculations\n",
- "Q = m_h*cph*(t_h1-t_h2);\n",
- "t_c2 = m_h*cph/cpc*(t_h1-t_h2)/m_c+t_c1;\n",
- "theta = ((t_h1-t_c1)- (t_h2-t_c2))/math.log((t_h1-t_c1)/(t_h2-t_c2)); \t\t\t#Logarithmic mean temperature difference\n",
- "U = hi*h0/(hi+h0);\n",
- "A = Q*10**3/U/theta;\n",
- "\n",
- "# Results\n",
- "print (\"The area of heat exchanger = %.3f\")% (A), (\"m**2\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The area of heat exchanger = 2.655 m**2\n"
- ]
- }
- ],
- "prompt_number": 20
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.19 page no : 827"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# Variables\n",
- "t_c1 = 25.; \t\t\t#0C\n",
- "t_c2 = 65.; \t\t\t#0C\n",
- "cph = 1.45; \t\t\t#kJ/kg K\n",
- "m_h = 0.9; \t\t \t#kg/s\n",
- "t_h1 = 230.; \t\t\t#0C\n",
- "t_h2 = 160.; \t\t\t#0C\n",
- "U = 420.; \t \t\t#W/m**2 0C\n",
- "cpc = 4.187; \t\t\t#kJ/kg K\n",
- "\n",
- "# Calculations and Results\n",
- "Q = m_h*cph*(t_h1-t_h2);\n",
- "print (\"(i) The rate of heat transfer = \"), (Q), (\"kJ/s\")\n",
- "\n",
- "m_c = Q/cpc/(t_c2-t_c1);\n",
- "print (\"(ii) The mass flow rate of water = %.3f\")% (m_c), (\"kg/s\")\n",
- "\n",
- "\n",
- "print (\"(iii) The surface area of heat exchanger = \")\n",
- "LMTD = ((t_h1-t_c2)- (t_h2-t_c1))/math.log((t_h1-t_c2)/(t_h2-t_c1)); \t\t\t#math.logarithmic mean temperature difference\n",
- "A = Q*10**3/U/LMTD;\n",
- "print (\"A = %.3f\")% (A), (\"m**2\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "(i) The rate of heat transfer = 91.35 kJ/s\n",
- "(ii) The mass flow rate of water = 0.545 kg/s\n",
- "(iii) The surface area of heat exchanger = \n",
- "A = 1.455 m**2\n"
- ]
- }
- ],
- "prompt_number": 21
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.20 page no : 828"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "m_s = 800./60; \t\t\t#kg/s\n",
- "m_c = m_s;\n",
- "m_g = 1350./60; \t\t\t#kg/s\n",
- "m_h = m_g;\n",
- "t_h1 = 650.; \t\t\t#0C\n",
- "t_c1 = 180.; \t\t\t#0C\n",
- "t_c2 = 350.; \t\t\t#0C\n",
- "d = 0.03; \t\t\t#m\n",
- "L = 3.; \t\t\t#m\n",
- "cph = 1.; \t\t\t#kJ/kg K\n",
- "cpc = 2.71; \t\t\t#kJ/kg K\n",
- "h_g = 250.;\n",
- "h_s = 600.;\n",
- "\n",
- "# Calculations\n",
- "t_h2 = round(t_h1-(m_c*cpc*(t_c2-t_c1)/cph/m_h));\n",
- "U = round(h_g*h_s/(h_g+h_s),1);\n",
- "Q = round(m_h*(cph*10**3)*(t_h1-t_h2),1);\n",
- "theta = ((t_h1-t_c2)- (t_h2-t_c1))/math.log((t_h1-t_c2)/(t_h2-t_c1));# logarithmic mean temperature differenceN = Q/U/theta/(math.pi*d*L);\n",
- "\n",
- "\n",
- "# Results\n",
- "print (\"%.1f\")% (theta), (\"C\")\n",
- "\n",
- "N = (6142.5 * 10**3)/(U * 0.2827* theta)\n",
- "print \"number of tubes required = %.0f\" % N\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "244.9 C\n",
- "number of tubes required = 503\n"
- ]
- }
- ],
- "prompt_number": 31
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.21 page no : 829"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "\n",
- "# Variables\n",
- "di = 0.0296; \t\t\t#m\n",
- "d0 = 0.0384; \t\t\t#m\n",
- "U = 4000.; \t\t\t#W/m**2 0C\n",
- "V = 3.; \t\t\t#m/s\n",
- "t_c1 = 24.; \t\t\t#0C\n",
- "x = 0.9;\n",
- "ps = (760-660.)/760*1.0133; \t\t\t#bar\n",
- "t_h1 = 51.; \t\t\t#0C\n",
- "t_h2 = 51.; \t\t\t#0C\n",
- "h_fg = 2592.; \t\t\t#kJ/kg\n",
- "t_c2 = 47.; \t\t\t#0C\n",
- "P = 15.; \t\t\t#MW\n",
- "ssc = 5.; \t\t\t#specific steam consumption in kg/kWh\n",
- "cpc = 4.187; \t\t\t#kJ?kg K\n",
- "rho = 1000.;\n",
- "\n",
- "# Calculations and Results\n",
- "m_s = P*10.**3*ssc/60; \t\t\t#kg/min\n",
- "m_w = m_s*x*h_fg/cpc/(t_c2-t_c1);\n",
- "print (\"(i) Mass of cooling water circulated per minute = %.3f\")% (m_w), (\"kg/min\")\n",
- "\n",
- "\n",
- "Q = m_s*x*h_fg*10**3/60.;\n",
- "\n",
- "theta = ((t_h1-t_c1)- (t_h2-t_c2))/math.log((t_h1-t_c1)/(t_h2-t_c2)); \t\t\t#Logarithmic mean temperature difference\n",
- "A = Q/U/theta;\n",
- "print (\"(ii) Condenser surface area %.3f\")% (A), (\"m**2\")\n",
- "\n",
- "Np = m_w/60*4/math.pi/di**2/V/rho;\n",
- "print (\"(iii) Number of tubes required per pass = %.3f\")% (Np)\n",
- "\n",
- "L = A/math.pi/d0/(2*Np);\n",
- "print (\"(iv) Tube length = %.3f\")% (L), (\"m\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "(i) Mass of cooling water circulated per minute = 30280.059 kg/min\n",
- "(ii) Condenser surface area 1008.737 m**2\n",
- "(iii) Number of tubes required per pass = 244.462\n",
- "(iv) Tube length = 17.102 m\n"
- ]
- }
- ],
- "prompt_number": 23
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.22 page no : 831"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "cp = 4.187; \t\t\t#kJ/kg \u00b0C\n",
- "u = 0.596*10**(-3); \t#Ns/m**2\n",
- "k = 0.635; \t\t\t #W/m \u00b0C\n",
- "Pr = 3.93; \n",
- "d = 0.020; \t\t\t#m\n",
- "l = 2.; \t\t\t#m\n",
- "m_c = 10.; \t\t\t#kg/s\n",
- "t_c1 = 17.; \t\t#/\u00b0C\n",
- "t_h1 = 100.; \t\t#\u00b0C\n",
- "t_h2 = 100.; \t\t#\u00b0C\n",
- "rho = 1000.;\n",
- "N = 200.;\n",
- "Np = N/l;\n",
- "h0 = 10.*10**3;\n",
- "\n",
- "# Calculations\n",
- "V = m_c*4/math.pi/d**2/rho/Np;\n",
- "Re = rho*V*d/u;\n",
- "hi = k/d*0.023*(Re)**0.8*(Pr)**0.33;\n",
- "U = hi*h0/(hi+h0);\n",
- "t_c2 = (U*math.pi*d*l*N*91.5 + m_c*cp*10**3*t_c1)/(m_c*cp*10**3 + U*math.pi*d*l*N*0.5);\n",
- "\n",
- "# Results\n",
- "print (\"water exit temperature = %.3f\")% (t_c2), (\"\u00b0C\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "water exit temperature = 71.043 \u00b0C\n"
- ]
- }
- ],
- "prompt_number": 24
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.23 page no : 842"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "A = 0.12; \t\t\t#m**2\n",
- "T = 800.; \t\t\t#K\n",
- "a = 5.67*10**(-8);\n",
- "\n",
- "# Calculations and Results\n",
- "Eb = a*A*T**4;\n",
- "print (\"(i) The total rate of energy emission = %.3f\")% (Eb),(\"W\")\n",
- "\n",
- "Ibn = a*T**4/math.pi;\n",
- "print (\"(ii) The intensity of normal radiation = %.3f\")% (Ibn), (\"W/m**2.sr\")\n",
- "\n",
- "wavelength = 2898/T;\n",
- "print (\"(iii) The wavelength of maximum monochromatic emissive power = %.3f\")%(wavelength), (\"\u03bcm\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "(i) The total rate of energy emission = 2786.918 W\n",
- "(ii) The intensity of normal radiation = 7392.531 W/m**2.sr\n",
- "(iii) The wavelength of maximum monochromatic emissive power = 3.623 \u03bcm\n"
- ]
- }
- ],
- "prompt_number": 25
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.24 page no : 842"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# Variables\n",
- "wavelength = 0.49; \t\t\t#\u03bcm\n",
- "a = 5.67*10**(-8);\n",
- "\n",
- "# Calculations and Results\n",
- "T = 2898/wavelength;\n",
- "print (\"(i) The surface temperature of the sun %.3f\")% (T), (\"K\")\n",
- "\n",
- "E_sun = a*T**4;\n",
- "print (\"(ii) The heat flux at the surface of the sun = %.3f\")% (E_sun/1E+7), (\"*10^7 W/m**2\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "(i) The surface temperature of the sun 5914.286 K\n",
- "(ii) The heat flux at the surface of the sun = 6.937 *10^7 W/m**2\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.25 page no : 843"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "\n",
- "# Variables\n",
- "T = 2773. \t\t\t#K\n",
- "lambda_ = 1.2 * 10**-6\n",
- "e = 0.9;\n",
- "a = 5.67*10**(-8);\n",
- "\n",
- "# Calculations and Results\n",
- "print (\"(i) Monochromatic emissive power at 1.2 \u03bcm length\")\n",
- "C1 = 0.3742*10**(-15); \t\t\t#W.m**4/m**2\n",
- "C2 = 1.4388*10**(-4); \t\t\t#mK\n",
- "E_lambda_b = C1*lambda_**(-5)/((math.exp(C2/lambda_/T)-1));\n",
- "\n",
- "print (\"E_lambda_b = %.2e\")% (E_lambda_b)\n",
- "\n",
- "lambda_max = 2898/T;\n",
- "print (\"(ii) Wavelength at which the emission is maximum = %.3f\")% (lambda_max), (\"\u03bcm\")\n",
- "\n",
- "E_lambda_b_max = 1.285*10.**(-5)*T**5;\n",
- "print (\"(iii) Maximum emissive power = %.3f\")% (E_lambda_b_max/1E+12), (\"*10^12 W/m**2 per metre length\")\n",
- "\n",
- "Eb = a*T**4;\n",
- "print (\"(iv) Total emissive power = %.3f\")% (Eb/1E+6), (\"*10^6 W/m**2\")\n",
- "\n",
- "E = e*a*T**4;\n",
- "print (\"(v) Total emissive power = %.3f\")% (E/1E+6), (\"*10^6 W/m**2\")\n",
- "\n",
- "# Book answers are wrong. Please calculate them manually."
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "(i) Monochromatic emissive power at 1.2 \u03bcm length\n",
- "E_lambda_b = 3.40e+15\n",
- "(ii) Wavelength at which the emission is maximum = 1.045 \u03bcm\n",
- "(iii) Maximum emissive power = 2.107 *10^12 W/m**2 per metre length\n",
- "(iv) Total emissive power = 3.353 *10^6 W/m**2\n",
- "(v) Total emissive power = 3.017 *10^6 W/m**2\n"
- ]
- }
- ],
- "prompt_number": 40
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.26 page no : 845"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# Variables\n",
- "T1 = 1273.; \t\t\t#K\n",
- "T2 = 773.; \t\t\t#K\n",
- "e1 = 0.42;\n",
- "e2 = 0.72;\n",
- "a = 5.67*10**(-8);\n",
- "\n",
- "# Calculations and Results\n",
- "print (\"(i) When the body is grey with \u03b51 = 0.42\")\n",
- "q = e1*a*(T1**4-T2**4)/10**3; \t\t\t#kW\n",
- "print (\"Heat loss per m2 by radiation = %.3f\")% (q), (\"kW\")\n",
- "print (\"(ii) When the body is not grey\")\n",
- "E_emitted = e1*a*T1**4;\n",
- "E_absorbed = e2*a*(T2)**4;\n",
- "q = (E_emitted-E_absorbed)/10**3;\n",
- "print (\"Heat loss per m2 by radiation = %.3f\")% (q), (\"kW\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "(i) When the body is grey with \u03b51 = 0.42\n",
- "Heat loss per m2 by radiation = 54.036 kW\n",
- "(ii) When the body is not grey\n",
- "Heat loss per m2 by radiation = 47.962 kW\n"
- ]
- }
- ],
- "prompt_number": 28
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.27 page no : 846"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "d = 0.022; \t\t\t#m\n",
- "di = 0.18; \t\t\t#m\n",
- "e1 = 0.62;\n",
- "e2 = 0.82;\n",
- "rho = 7845.; \t\t\t#kg/m**3\n",
- "T1a = 693.; \t\t\t#K; For caseI\n",
- "T1b = 813.; \t\t\t#K; For caseII\n",
- "T2 = 1373.; \t\t\t#K\n",
- "l = 1.; \t\t\t#m\n",
- "a = 5.67*10**(-8); \n",
- "cp = 0.67; \t\t\t#kJ/kg K\n",
- "\n",
- "# Calculations\n",
- "A1 = math.pi*d*l;\n",
- "A2 = math.pi*di*l;\n",
- "Qi = A1*a*(T1a**4-T2**4)/(1/e1+A1/A2*(1/e2 - 1));\n",
- "Qe = A1*a*(T1b**4-T2**4)/(1/e1+A1/A2*(1/e2 - 1));\n",
- "Qav = -(Qi+Qe)/2;\n",
- "t_h = math.pi/4*d**2*rho*cp*(T1b-T1a)*10**3/Qav;\n",
- "\n",
- "# Results\n",
- "print (\"Time required for the heating operation %.3f\")% (t_h),(\"s\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Time required for the heating operation 31.157 s\n"
- ]
- }
- ],
- "prompt_number": 29
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.28 page no : 847"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# Variables\n",
- "r1 = 0.05; \t\t\t#m\n",
- "r2 = 0.1; \t\t\t#m\n",
- "T1 = 400.; \t\t\t#K\n",
- "T2 = 300.; \t\t\t#K\n",
- "e1 = 0.5;\n",
- "e2 = 0.5;\n",
- "F_12 = 1.;\n",
- "\n",
- "# Calculations\n",
- "a = 5.67*10**(-8);\n",
- "#A1/A2 = r1/r2\n",
- "Q = a*(T1**4-T2**4)/((1-e1)/e1+1/F_12+(1-e2)/e2*r1/r2);\n",
- "\n",
- "# Results\n",
- "print (\"heat transfer rate per m2 area by radiation\"), (Q), (\"W/m**2\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "heat transfer rate per m2 area by radiation 396.9 W/m**2\n"
- ]
- }
- ],
- "prompt_number": 30
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.29 page no : 847"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# Variables\n",
- "r1 = 0.05; \t\t\t#m\n",
- "r2 = 0.1; \t\t\t#m\n",
- "r3 = 0.15; \t\t\t#m\n",
- "T1 = 1000.; \t\t\t#K\n",
- "T3 = 500.; \t\t\t#K\n",
- "e1 = 0.05;\n",
- "e2 = e1;\n",
- "e3 = e1;\n",
- "a = 5.67*10**(-8);\n",
- "F_12 = 1.;\n",
- "F_23 = 1.;\n",
- "T2 = 770.; \t\t\t#K\n",
- "\n",
- "# Calculations\n",
- "Q1 = a*(T1**4-T2**4)/(((1-e1)/e1) + 1/F_12 + ((1-e2)/e2)*r1/r2);\n",
- "\n",
- "# Results\n",
- "print (\"Heat flow per m2 area of cylinder 1 = %.3f\")% (Q1), (\"W\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Heat flow per m2 area of cylinder 1 = 1246.381 W\n"
- ]
- }
- ],
- "prompt_number": 31
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.30 page no : 848"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "# Variables\n",
- "r1 = 0.105; \t\t\t#m\n",
- "r2 = 0.15; \t\t\t#m\n",
- "T1 = 120.; \t\t\t#K\n",
- "T2 = 300.; \t\t\t#K\n",
- "e1 = 0.03;\n",
- "e2 = 0.03;\n",
- "h_fg = 209.35; \t\t\t#kJ/kg\n",
- "a = 5.67*10**(-8);\n",
- "F_12 = 1.;\n",
- "\n",
- "# Calculations\n",
- "Q = 4*math.pi*r1**2*a*(T1**4-T2**4)/( ((1-e1)/e1) + 1./F_12 + ((1-e2)/e2)*r1**2/r2**2);\n",
- "rate = -Q*3600./h_fg/1000;\n",
- "\n",
- "# Results\n",
- "print (\"Rate of evaporation = %.3f\")% (rate), (\"kg/h\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Rate of evaporation = 0.022 kg/h\n"
- ]
- }
- ],
- "prompt_number": 32
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.31 page no : 849"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "T1 = 91.; \t\t\t#K\n",
- "T2 = 303.; \t\t\t#K\n",
- "e1 = 0.03;\n",
- "e2 = 0.03;\n",
- "d1 = 0.3; \t\t\t#m\n",
- "d2 = 0.45; \t\t\t#m\n",
- "a = 5.67*10**(-8);\n",
- "F_12 = 1.;\n",
- "\n",
- "# Calculations\n",
- "Q = 4*math.pi*(d1/2)**2*a*(T1**4-T2**4)/( ((1-e1)/e1) + 1/F_12 + ((1-e2)/e2)*d1**2/d2**2);\n",
- "\n",
- "# Results\n",
- "print (\"Rate of heat flow = %.3f\")% (Q), (\"W\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Rate of heat flow = -2.810 W\n"
- ]
- }
- ],
- "prompt_number": 33
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 15.32 page no : 850"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "# Variables\n",
- "e1 = 0.3;\n",
- "e2 = 0.8;\n",
- "e3 = 0.04;\n",
- "A1 = 1.; \t\t\t#m**2\n",
- "A2 = A1;\n",
- "A3 = A1;\n",
- "\n",
- "# Calculations\n",
- "reduction = 1-0.131*0.52;\n",
- "\n",
- "# Results\n",
- "print (\"Percentage reduction in heat flow due to shield = %.3f\")% (reduction), (\"%\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Percentage reduction in heat flow due to shield = 0.932 %\n"
- ]
- }
- ],
- "prompt_number": 34
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch16.ipynb b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch16.ipynb
deleted file mode 100644
index 8e3b0a97..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch16.ipynb
+++ /dev/null
@@ -1,991 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:9c7b64e157d08f3c7a366b1cf2d1f4de4a886f7dc2475d29ec96bb2b10e8dc31"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 16 : Compressible Flow"
- ]
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.1 page no : 859"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "V1 = 300.; \t\t\t#m/s\n",
- "p1 = 78.; \t\t\t#kN/m**2\n",
- "T1 = 313.; \t\t\t#K\n",
- "p2 = 117.; \t\t\t#kN/m**2\n",
- "R = 287.; \t\t\t#J/kg K\n",
- "y = 1.4;\n",
- "\n",
- "# Calculations\n",
- "#Let r1 = p1/rho1\n",
- "r1 = R*T1;\n",
- "V2 = math.sqrt(2*(y/(y-1)*r1*(1-(p2/p1)**((y-1)/y)) + V1**2/2));\n",
- "\n",
- "# Results\n",
- "print (\"Velocity of gas at section 2 = %.3f\")% (V2), (\"m/s\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Velocity of gas at section 2 = 112.987 m/s\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.2 page no : 861"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# Variables\n",
- "p1 = 35.; \t\t\t#kN/m**2\n",
- "V1 = 30.; \t\t\t#m/s\n",
- "T1 = 423.; \t\t\t#K\n",
- "V2 = 150.; \t\t\t#m/s\n",
- "R = 290.; \t\t\t#J/kg K\n",
- "y = 1.4;\n",
- "\n",
- "# Calculations\n",
- "#Let r1 = p2/p1\n",
- "r1 = R*T1; \n",
- "p2 = p1*(1-((V2**2/2-V1**2/2)*(y-1)/y/r1))**(y/(y-1));\n",
- "print (\"pressure = %.3f\")% (p2), (\"kN/m**2\")\n",
- "\n",
- "T2 = T1*(p2/p1)**((y-1)/y);\n",
- "t2 = T2-273;\n",
- "print (\"temperature = %.3f\")% (t2), (\"\u00b0C\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "pressure = 32.014 kN/m**2\n",
- "temperature = 139.360 \u00b0C\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.3 page no : 866"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "SG = 0.8;\n",
- "rho_oil = 800.; \t\t\t#kg/m**3\n",
- "K_oil = 1.5*10**9; \t\t\t#N/m**2; crude oil\n",
- "K_Hg = 27*10.**9; \t\t\t#N/m**2; Mercury\n",
- "rho_Hg = 13600.; \t\t\t#kg/m**3\n",
- "\n",
- "# Calculations and Results\n",
- "C_oil = math.sqrt(K_oil/rho_oil);\n",
- "print (\"Sonic velocity of crude oil = %.3f\")% (C_oil), (\"m/s\")\n",
- "\n",
- "C_Hg = math.sqrt(K_Hg/rho_Hg)\n",
- "print (\"Sonic velocity of Mercury = %.3f\")% (C_Hg), (\"m/s\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Sonic velocity of crude oil = 1369.306 m/s\n",
- "Sonic velocity of Mercury = 1409.005 m/s\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.4 page no : 866"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "T = 228.; \t\t\t#K\n",
- "M = 2.;\n",
- "R = 287.; \t\t\t#Jkg K\n",
- "y = 1.4;\n",
- "\n",
- "# Calculations\n",
- "C = math.sqrt(y*R*T);\n",
- "V = M*C*3600./1000;\n",
- "\n",
- "# Results\n",
- "print (\"Velocity of the plane = %.3f\")% (V), (\"km/h\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Velocity of the plane = 2179.239 km/h\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.5 page no : 868"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "# Variables\n",
- "a = 40*math.pi/180; \t\t\t#Mach angle in radians\n",
- "y = 1.4;\n",
- "R = 287.; \t\t\t#J/kg K\n",
- "T = 288.; \t\t\t#K\n",
- "\n",
- "# Calculations\n",
- "C = math.sqrt(y*R*T);\n",
- "V = C/math.sin(a);\n",
- "\n",
- "# Results\n",
- "print (\"Velocity of bullet = %.3f\")% (V), (\"m/s\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Velocity of bullet = 529.217 m/s\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.6 page no : 868"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "p = 88.3; \t\t\t#kN/m**2\n",
- "T = 271.; \t\t\t#K\n",
- "M = 40.*math.pi/180;\n",
- "y = 1.4;\n",
- "R = 287.; \t\t\t#J/kg K\n",
- "\n",
- "# Calculations\n",
- "C = math.sqrt(y*R*T);\n",
- "V = C/math.sin(M);\n",
- "\n",
- "# Results\n",
- "print (\"Velocity of the projectile = %.3f\")% (V), (\"m/s\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Velocity of the projectile = 513.360 m/s\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.7 page no : 868"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "h = 1800.; \t\t\t#m\n",
- "T = 277.; \t\t\t#K\n",
- "t = 4.; \t\t\t#s\n",
- "y = 1.4;\n",
- "R = 287.; \t\t\t#J/kg K\n",
- "\n",
- "# Calculations\n",
- "C = math.sqrt(y*R*T);\n",
- "a = (math.cos(C/h*t));\n",
- "V = C/math.sin(a)*3600/1000;\n",
- "\n",
- "# Results\n",
- "print (\"Speed of the aircraft = %.3f\")% (V), (\"km/h\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Speed of the aircraft = 1785.959 km/h\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.8 page no : 873"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "R = 287.; \t\t\t#J/kg K\n",
- "y = 1.4;\n",
- "V0 = 1000.*1000/3600; \t\t\t#m/s\n",
- "p0 = 78.5; \t\t\t#kN/m**2\n",
- "T0 = 265.; \t\t\t#K\n",
- "\n",
- "# Calculations and Results\n",
- "C0 = math.sqrt(y*R*T0);\n",
- "M0 = V0/C0;\n",
- "\n",
- "ps = p0*(1+((y-1)/2*M0**2))**(y/(y-1));\n",
- "print (\"(i) Stagnation pressure = %.3f\")%(ps), (\"kN/m**2\")\n",
- "\n",
- "Ts = T0*(1+((y-1)/2*M0**2));\n",
- "print (\"(ii) Stagnation temperature = %.3f\")% (Ts), (\"K\")\n",
- "\n",
- "rho_s = ps*10**3/R/Ts;\n",
- "print (\"(iii) Stagnation density = %.3f\")%(rho_s), (\"kg/m**3\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "(i) Stagnation pressure = 126.067 kN/m**2\n",
- "(ii) Stagnation temperature = 303.407 K\n",
- "(iii) Stagnation density = 1.448 kg/m**3\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.9 page no : 874"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "V0 = 1000.*1000./3600; \t\t\t#m/s\n",
- "T0 = 320.; \t\t\t#K\n",
- "p_atm = 98.1; \t\t\t#kN/m**2\n",
- "p = 9.81; \t\t\t#kN/m**2\n",
- "p0 = 98.1-p;\n",
- "R = 287.; \t\t\t#J/kg K\n",
- "y = 1.4;\n",
- "\n",
- "# Calculations and Results\n",
- "C0 = math.sqrt(y*R*T0);\n",
- "M0 = V0/C0;\n",
- "\n",
- "ps = p0*(1+((y-1)/2*M0**2))**(y/(y-1));\n",
- "print (\"Stagnation pressure = %.3f\")% (ps), (\"kN/m**2\")\n",
- "\n",
- "Ts = T0*(1+((y-1)/2*M0**2));\n",
- "print (\"Stagnation temperature = %.1f\")% (Ts), (\"K\")\n",
- "\n",
- "rho_s = ps*10**3/R/Ts;\n",
- "print (\"Stagnation density = %.3f\")% (rho_s), (\"kg/m**3\")\n",
- "\n",
- "M = 0.8;\n",
- "\n",
- "CF = 1+(M0**2./4)+((2-y)/24.*M0**4);\n",
- "print (\"Compressibility factor %.2f\")% (CF)\n",
- "\n",
- "#Note : Answers are slightly different because of rounding error."
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Stagnation pressure = 131.282 kN/m**2\n",
- "Stagnation temperature = 358.4 K\n",
- "Stagnation density = 1.276 kg/m**3\n",
- "Compressibility factor 1.16\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.10 page no : 875"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "R = 287.; \t\t\t#J/kg K\n",
- "y = 1.4;\n",
- "p0 = 220.*10**3; \t#N/m**2\n",
- "T0 = 300.; \t\t\t#K\n",
- "V0 = 200.; \t\t\t#m/s\n",
- "\n",
- "# Calculations and Results\n",
- "C0 = math.sqrt(y*R*T0);\n",
- "rho_0 = p0/R/T0;\n",
- "print (\"Stagnation pressure = \")\n",
- "\n",
- "print (\"(i) Compressibility is neglected\")\n",
- "ps = (p0+rho_0*V0**2/2)/10**3;\n",
- "print (\"ps = %.3f\")% (ps), (\"kN/m**2\")\n",
- "\n",
- "print (\"(ii) Compressibility is accounted for\")\n",
- "M0 = V0/C0;\n",
- "\n",
- "ps = (p0+rho_0*V0**2/2*(1+M0**2./4+(2-y)/24*M0**4))/10**3;\n",
- "print (\"ps = %.3f\")% (ps), (\"kN/m**2\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Stagnation pressure = \n",
- "(i) Compressibility is neglected\n",
- "ps = 271.103 kN/m**2\n",
- "(ii) Compressibility is accounted for\n",
- "ps = 275.484 kN/m**2\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.11 page no : 875"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "p0 = 35.*10**3; \t\t\t#Pa\n",
- "T0 = 235.; \t\t\t#K\n",
- "ps = 65.4*10**3; \t\t\t#N/m**2\n",
- "R0 = 8314.; \t\t\t#Nm/mole K\n",
- "M = 28.;\n",
- "\n",
- "# Calculations\n",
- "R = R0/M;\n",
- "rho_0 = p0/R/T0;\n",
- "Va = math.sqrt(2*(ps-p0)/rho_0);\n",
- "\n",
- "# Results\n",
- "print (\"Speed of the aircraft = %.3f\")% (Va), (\"m/s\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Speed of the aircraft = 348.159 m/s\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.12 page no : 885"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "p0 = 30.*10**3; \t\t\t#N/m**2\n",
- "V0 = 152.; \t\t\t#m/s\n",
- "y = 1.4;\n",
- "rho_0 = 1.224; \t\t\t#kg/m**3\n",
- "ps = p0+rho_0*V0**2/2;\n",
- "\n",
- "# Calculations\n",
- "rho_0 = 0.454; \t\t\t#kg/m**3\n",
- "V0 = math.sqrt(2*(ps-p0)/rho_0);\n",
- "C0 = math.sqrt(y*p0/rho_0);\n",
- "M = V0/C0;\n",
- "ccf = (1+M**2/4); \t\t\t#Compressibility correction factor\n",
- "V = V0/math.sqrt(ccf); \t\t\t#True speed of aircraft\n",
- "\n",
- "# Results\n",
- "print (\"True speed of aircraft = %.3f\")% (V), (\"m/s\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "True speed of aircraft = 230.900 m/s\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.13 page no : 886"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "M = 3.; \t\t\t#Mach number\n",
- "d = 0.2; \t\t\t#m\n",
- "p_nozzle = 7.85; \t\t\t#kN/m**2\n",
- "T_nozzle = 200.; \t\t\t#K\n",
- "y = 1.4;\n",
- "\n",
- "# Calculations and Results\n",
- "A = math.pi/4*d**2;\n",
- "p_res = p_nozzle*(1+((y-1)/2*M**2))**(y/(y-1));\n",
- "print (\"Reservoir pressure = %.3f\")% (p_res), (\"kN/m**2\")\n",
- "\n",
- "T_res = T_nozzle*(1+((y-1)/2*M**2));\n",
- "print (\"Reservoir temperature = %.3f\")% (T_res), (\"K\")\n",
- "\n",
- "Ac = A*M/((2+(y-1)*M**2)/(y+1))**((y+1)/2/(y-1));\n",
- "print (\"Throat area (critical) = %.5f\")% (Ac), (\"m**2\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Reservoir pressure = 288.352 kN/m**2\n",
- "Reservoir temperature = 560.000 K\n",
- "Throat area (critical) = 0.00742 m**2\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.14 page no : 887"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "R = 287.; \t\t\t#J/kg K\n",
- "y = 1.4;\n",
- "p_atm = 100.; \t\t\t#kN/m**2\n",
- "p1 = 284. + p_atm; \t\t\t#kN/m**2\n",
- "T1 = 297.; \t \t\t#K\n",
- "D = 0.02; \t\t \t#m\n",
- "\n",
- "# Calculations\n",
- "A2 = math.pi/4*D**2;\n",
- "rho_1 = p1*10**3/R/T1;\n",
- "m_max = 0.685*A2*math.sqrt(p1*10**3*rho_1);\n",
- "\n",
- "# Results\n",
- "print (\"Maximum flow rate = %.3f\")% (m_max), (\"kg/s\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Maximum flow rate = 0.283 kg/s\n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.15 page no : 888"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# Variables\n",
- "R = 287.; \t\t\t#J/kg K\n",
- "y = 1.4;\n",
- "p1 = 2500.*10**3; \t#N/m**2\n",
- "T1 = 293.; \t\t\t#K\n",
- "p2 = 1750.*10**3; \t#N/m**2\n",
- "\n",
- "# Calculations\n",
- "rho_1 = p1/R/T1;\n",
- "V2 = math.sqrt(2*y/(y-1)*p1/rho_1*(1-(p2/p1)**((y-1)/y)));\n",
- "\n",
- "# Results\n",
- "print (\"Velocity of air = %.3f\")% (V2),(\"m/s\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Velocity of air = 238.812 m/s\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.16 page no : 889"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "R = 287.; \t \t\t#J/kg K\n",
- "y = 1.4;\n",
- "p_atm = 10.**5; \t\t#N/m**2\n",
- "T1 = 293. \t\t\t#K\n",
- "D2 = 0.025; \t\t\t#m\n",
- "p1 = 140.*10**3; \t\t#N/m**2\n",
- "\n",
- "# Calculations and Results\n",
- "A2 = math.pi/4*D2**2;\n",
- "\n",
- "print (\"(i) Mass rate of flow of air when pressure in the math.tank is 140 kN/m2 (abs.)\")\n",
- "rho_1 = p1/R/T1;\n",
- "p2 = 10**5; \t\t\t#N/m**2\n",
- "\n",
- "m = A2*math.sqrt(2*y/(y-1)*p1*rho_1*((p2/p1)**(2/y) - (p2/p1)**((y+1)/y)));\n",
- "print (\"m = %.3f\")% (m), (\"kg/s\")\n",
- "\n",
- "print (\"(ii) Mass rate of flow of air when pressure in the math.tank is 300 kN/m2 (abs.)\")\n",
- "p1 = 300.*10**3; \t\t\t#N/m**2\n",
- "p2 = 10.**5; \t\t\t#N/m**2\n",
- "rho_1 = p1/R/T1;\n",
- "\n",
- "print (\"The pressure ratio p2/p1 being less than the critical ratio 0.528, the flow in the nozzle will be sonic\");\n",
- "\n",
- "m_max = 0.685*A2*math.sqrt(p1*rho_1);\n",
- "print (\"m_max = %.3f\")% (m_max), (\"kg/s\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "(i) Mass rate of flow of air when pressure in the math.tank is 140 kN/m2 (abs.)\n",
- "m = 0.149 kg/s\n",
- "(ii) Mass rate of flow of air when pressure in the math.tank is 300 kN/m2 (abs.)\n",
- "The pressure ratio p2/p1 being less than the critical ratio 0.528, the flow in the nozzle will be sonic\n",
- "m_max = 0.348 kg/s\n"
- ]
- }
- ],
- "prompt_number": 18
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.17 page no : 890"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "p1 = 200.; \t\t\t#kN/m**2\n",
- "V1 = 170.; \t\t\t#m/s\n",
- "T1 = 473.; \t\t\t#K\n",
- "A1 = 0.001; \t\t#m**2\n",
- "R = 287.; \t\t\t#J/kg K\n",
- "cp = 1000.; \t\t#J/kg K\n",
- "y = 1.4;\n",
- "\n",
- "# Calculations and Results\n",
- "print (\"(i) Stagnation temperature (Ts) and stagnation pressure (ps)\")\n",
- "\n",
- "Ts = T1+V1**2/2/cp;\n",
- "print (\"Ts = %.3f\")% (Ts), (\"K\")\n",
- "\n",
- "ps = p1*(Ts/T1)**(y/(y-1));\n",
- "print (\"ps = %.3f\")% (ps), (\"kN/m**2\")\n",
- "\n",
- "print (\"(ii) Sonic velocity and Mach number at this section\")\n",
- "\n",
- "C1 = math.sqrt(y*R*T1);\n",
- "print (\"Sonic velocity = %.3f\")% (C1), (\"m/s\")\n",
- "\n",
- "M1 = V1/C1;\n",
- "print (\"Mach number = %.3f\")% (M1)\n",
- "\n",
- "print (\"(iii) Velocity, Mach number and flow area at outlet section where pressure is 110 kN/m2\")\n",
- "p2 = 110.; \t\t\t#kN/m**2\n",
- "M2 = math.sqrt(2/(y-1)*((ps/p2)**((y-1)/y) - 1));\n",
- "print (\"M2 = %.3f\")% (M2)\n",
- "\n",
- "T2 = Ts*(p2/ps)**((y-1)/y);\n",
- "C2 = math.sqrt(y*R*T2);\n",
- "V2 = M2*C2;\n",
- "print (\"V2 = %.3f\")% (V2), (\"m/s\")\n",
- "\n",
- "A2 = (p1*A1*V1*T2/T1/p2/V2)*10**6;\n",
- "print (\"A2 = %.3f\")% (A2), (\"mm**2\")\n",
- "\n",
- "\n",
- "print (\"(iv) Pressure (pt), temperature (Tt), velocity (Vt), and flow area (At) at throat of the nozzle\")\n",
- "Mt = 1.;\n",
- "Tt = Ts/(1+(y-1)/2*Mt**2);\n",
- "print (\"Tt = %.3f\")% (Tt), (\"K\")\n",
- "\n",
- "pt = ps*(Tt/Ts)**(y/(y-1));\n",
- "print (\"pt = %.3f\")% (pt), (\"kN/m**2\")\n",
- "\n",
- "Ct = math.sqrt(y*R*Tt);\n",
- "Vt = Mt*Ct;\n",
- "\n",
- "At = (p1*A1*V1*Tt/T1/pt/Vt)*10**6;\n",
- "print (\"At = %.3f\")% (At), (\"mm**2\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "(i) Stagnation temperature (Ts) and stagnation pressure (ps)\n",
- "Ts = 487.450 K\n",
- "ps = 222.214 kN/m**2\n",
- "(ii) Sonic velocity and Mach number at this section\n",
- "Sonic velocity = 435.949 m/s\n",
- "Mach number = 0.390\n",
- "(iii) Velocity, Mach number and flow area at outlet section where pressure is 110 kN/m2\n",
- "M2 = 1.055\n",
- "V2 = 422.183 m/s\n",
- "A2 = 617.168 mm**2\n",
- "(iv) Pressure (pt), temperature (Tt), velocity (Vt), and flow area (At) at throat of the nozzle\n",
- "Tt = 406.208 K\n",
- "pt = 117.392 kN/m**2\n",
- "At = 615.673 mm**2\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.18 page no : 893"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "y = 1.4;\n",
- "p1 = 26.5; \t\t\t#kN/m**2\n",
- "rho_1 = 0.413; \t\t\t#kg/m**3\n",
- "M1 = 2.;\n",
- "R = 287.;\n",
- "\n",
- "# Calculations and Results\n",
- "M2 = math.sqrt(((y-1)*M1**2 + 2)/(2*y*M1**2 - (y-1)));\n",
- "print (\"Mach number M2 = %.3f\")% (M2)\n",
- "\n",
- "p2 = p1*(2*y*M1**2 - (y-1))/(y+1);\n",
- "print (\"p2 = %.3f\")% (p2), (\"kN/m**2\")\n",
- "\n",
- "rho_2 = rho_1*((y+1)*M1**2)/((y-1)*M1**2 + 2);\n",
- "print (\"density, rho_2 = %.3f\")% (rho_2), (\"kg/m**3\")\n",
- "\n",
- "T1 = p1*10**3/rho_1/R;\n",
- "print (\"T1 = %.3f\")% (T1), (\"K\")\n",
- "\n",
- "T2 = T1*((y-1)*M1**2 + 2)*(2*y*M1**2 - (y-1))/((y+1)**2*M1**2);\n",
- "print (\"T2 = %.3f\")% (T2), (\"K\")\n",
- "\n",
- "C1 = math.sqrt(y*R*T1);\n",
- "V1 = M1*C1;\n",
- "print (\"V1 = %.3f\")% (V1), (\"m/s\")\n",
- "\n",
- "C2 = math.sqrt(y*R*T2);\n",
- "V2 = M2*C2;\n",
- "print (\"V2 = %.3f\")% (V2), (\"m/s\")\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Mach number M2 = 0.577\n",
- "p2 = 119.250 kN/m**2\n",
- "density, rho_2 = 1.101 kg/m**3\n",
- "T1 = 223.570 K\n",
- "T2 = 377.275 K\n",
- "V1 = 599.435 m/s\n",
- "V2 = 224.788 m/s\n"
- ]
- }
- ],
- "prompt_number": 20
- },
- {
- "cell_type": "heading",
- "level": 3,
- "metadata": {},
- "source": [
- "Example 16.19 page no : 895"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "import math \n",
- "\n",
- "# Variables\n",
- "M1 = 1.5;\n",
- "p1 = 170.; \t\t\t#kN/m**2\n",
- "T1 = 296.; \t\t\t#K\n",
- "y = 1.4;\n",
- "\n",
- "# Calculations and Results\n",
- "print (\"(i) Pressure, temperature and Mach number downstream of the shock\")\n",
- "p2 = p1*(2*y*M1**2 - (y-1))/(y+1);\n",
- "print (\"p2 = %.3f\")% (p2), (\"kN/m**2\")\n",
- "\n",
- "T2 = T1*((y-1)*M1**2 + 2)*(2*y*M1**2 - (y-1))/(y+1)**2/M1**2;\n",
- "print (\"T2 = %.3f\")% (T2), (\"K\")\n",
- "\n",
- "M2 = math.sqrt(((y-1)*M1**2 + 2)/(2*y*M1**2 - (y-1)));\n",
- "print (\"M2 = %.3f\")% (M2)\n",
- "\n",
- "strength = p2/p1 - 1;\n",
- "print (\"Strength of stock = %.3f\")% (strength)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "(i) Pressure, temperature and Mach number downstream of the shock\n",
- "p2 = 417.917 kN/m**2\n",
- "T2 = 390.784 K\n",
- "M2 = 0.701\n",
- "Strength of stock = 1.458\n"
- ]
- }
- ],
- "prompt_number": 21
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch2.ipynb b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch2.ipynb
deleted file mode 100644
index 7167565e..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch2.ipynb
+++ /dev/null
@@ -1,623 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:6dd70c1f71cf7fe5898008fd909312cd4643245d1663bc204223830088a91083"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# prints the value of a boolean variable:\n",
- "flag=False\n",
- "print \"flag = %r\" % flag\n",
- "flag = True\n",
- "print \"flag = %r\" % flag"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "flag = False\n",
- "flag = True\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# prints the character and its internally stored\n",
- "c='A'\n",
- "print \"c = \" + c + \", int(c) = %d\" % ord(c)\n",
- "c='t'\n",
- "print \"c = \" + c + \", int(c) = %d\" % ord(c)\n",
- "c='\\t' # the tab character\n",
- "print \"c = \" + c + \", int(c) = %d\" % ord(c)\n",
- "c='!'\n",
- "print \"c = \" + c + \", int(c) = %d\" % ord(c)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "c = A, int(c) = 65\n",
- "c = t, int(c) = 116\n",
- "c = \t, int(c) = 9\n",
- "c = !, int(c) = 33\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import sys\n",
- "# defines the constants SHRT_MIN, etc.\n",
- "print 'maximum limit int : ',\n",
- "print sys.maxint\n",
- "print 'float info'\n",
- "print sys.float_info"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "maximum limit int : 2147483647\n",
- "float info\n",
- "sys.float_info(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308, min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53, epsilon=2.220446049250313e-16, radix=2, rounds=1)\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# tests operators +, -, *, /, and %:\n",
- "m=54\n",
- "n=20\n",
- "print \"m = %d and n = %d\" %(m,n)\n",
- "print \"m+n = %d\" % (m+n) # 54+20 = 74\n",
- "print \"m-n = %d\" % (m-n) # 54-20 = 34\n",
- "print \"m*n = %d\" % (m*n)# 54*20 = 1080\n",
- "print \"m/n = %d\" % (m/n) # 54/20 = 2\n",
- "print \"m modulo by n = %d\" % (m%n) # 54%20 = 14"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "m = 54 and n = 20\n",
- "m+n = 74\n",
- "m-n = 34\n",
- "m*n = 1080\n",
- "m/n = 2\n",
- "m modulo by n = 14\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# shows the difference between m++ and ++m:\n",
- "m = 44\n",
- "m += 1\n",
- "n = m\n",
- "print \"m = %d , n = %d\" %(m,n)\n",
- "m = 44\n",
- "n = m # the post-increment operator is applied to m\n",
- "m += 1\n",
- "print \"m = %d , n = %d\" %(m,n)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "m = 45 , n = 45\n",
- "m = 45 , n = 44\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "code",
- "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",
- "print \"After n += 9, n = %d\" % n\n",
- "n -= 5 # subtracts 5 from n\n",
- "print \"After n -= 5, n = %d\" % n\n",
- "n *= 2 # multiplies n by 3\n",
- "print \"After n *= 2, n = %d\" % n \n",
- "n /= 3 # divides n by 9\n",
- "print \"After n /= 3, n = %d\" % n \n",
- "n %= 7 # reduces n to the remainder from dividing by 4\n",
- "print 'After n modulo by 7 n = %d' %n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "n = 22\n",
- "After n += 9, n = 31\n",
- "After n -= 5, n = 26\n",
- "After n *= 2, n = 52\n",
- "After n /= 3, n = 17\n",
- "After n modulo by 7 n = 3\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# tests the floating-point operators +, -, *, and /:\n",
- "x=54.0\n",
- "y=20.0\n",
- "print \"x = %f and y = %f\" %(x,y)\n",
- "print \"x+y = %f\" %(x+y) # 54.0+20.0 = 74.0\n",
- "print \"x-y = %f\" % (x-y) # 54.0-20.0 = 34.0\n",
- "print \"x*y = %f\" %( x*y) # 54.0*20.0 = 1080.0\n",
- "print \"x/y = %f\" % (x/y) # 54.0/20.0 = 2.7\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "x = 54.000000 and y = 20.000000\n",
- "x+y = 74.000000\n",
- "x-y = 34.000000\n",
- "x*y = 1080.000000\n",
- "x/y = 2.700000\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import sys\n",
- "# prints the storage sizes of the fundamental types:\n",
- "print \"Number of bytes used:\\n\"\n",
- "\n",
- "print \" char: %d \" % sys.getsizeof('a')\n",
- "print \" int : %d \" % sys.getsizeof(int(1))\n",
- "print \" string : %d \" % sys.getsizeof(str('hellololdei'))\n",
- "print \"float : %d\" % sys.getsizeof(float(1.1))"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Number of bytes used:\n",
- "\n",
- " char: 22 \n",
- " int : 12 \n",
- " string : 32 \n",
- "float : 16\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import sys\n",
- "# prints the storage sizes of the fundamental types:\n",
- "fbits = 8*sys.getsizeof(float(123))\n",
- "\n",
- "# each byte contains 8 bits\n",
- "print \"float uses : %d bits:\\n\\t\" % fbits \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "float uses : 128 bits:\n",
- "\t\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# casts a double value as an int:\n",
- "v = 1234.56789\n",
- "n = int(v);\n",
- "print \"v = %f, n = %d\" %(v,n)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "v = 1234.567890, n = 1234\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "code",
- "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",
- "print \"k = \" + k \n",
- "m=k;\n",
- "print \"m = \" + m \n",
- "n=m\n",
- "print \"n = \" + n\n",
- "x=m\n",
- "print \"x = \" + x \n",
- "y=x\n",
- "print \"y = \" + y"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "char c = A\n",
- "k = A\n",
- "m = A\n",
- "n = A\n",
- "x = A\n",
- "y = A\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "code",
- "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",
- "print \"n = %d\" % n\n",
- "n *= 1000 # multiplies n by 1000\n",
- "print \"n = %d\" % n\n",
- "n *= 1000 # multiplies n by 1000\n",
- "print \"n = %d\" % n\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "n = 1000\n",
- "n = 1000000\n",
- "n = 1000000000\n",
- "n = 1000000000000\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "code",
- "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",
- "print \"x = %f\" % x\n",
- "x *= x # multiplies n by itself; i.e., it squares x\n",
- "print \"x = %f\" % x\n",
- "x *= x # multiplies n by itself; i.e., it squares x\n",
- "print \"x = %f\" % x\n",
- "x *= x # multiplies n by itself; i.e., it squares x\n",
- "print \"x = %f\" % x\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "x = 1000.000000\n",
- "x = 1000000.000000\n",
- "x = 1000000000000.000000\n",
- "x = 999999999999999983222784.000000\n",
- "x = 1000000000000000043845843045076197354634047651840.000000\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# illustrates round-off error::\n",
- "x = 1000/3.0\n",
- "print \"x = %f\" %x # x = 1000/3\n",
- "y = x - 333.0\n",
- "print \"y = %f\" % y # y = 1/3\n",
- "z = 3*y - 1.0\n",
- "print \"z = %f\" %z # z = 3(1/3) - 1\n",
- "if (z == 0):\n",
- " print \"z == 0.\\n\"\n",
- "else:\n",
- " print \"z does not equal 0.\\n\" # z != 0\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "x = 333.333333\n",
- "y = 0.333333\n",
- "z = -0.000000\n",
- "z does not equal 0.\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "\n",
- "# implements the quadratic formula\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",
- "\n",
- "print \"The equation is: \",\n",
- "print a,\n",
- "print \"*x*x + \",\n",
- "print b,\n",
- "print \"*x + \" ,\n",
- "print c,\n",
- "print \" = 0\" \n",
- "\n",
- "d = b*b - 4*a*c # discriminant\n",
- "sqrtd = math.sqrt(d)\n",
- "x1 = (-b + sqrtd)/(2*a)\n",
- "x2 = (-b - sqrtd)/(2*a)\n",
- "print \"The solutions are:\"\n",
- "print \"\\tx1 = %f\" % x1\n",
- "print \"\\tx2 = %f\" % x2\n",
- "print \"Check:\" \n",
- "print \"\\ta*x1*x1 + b*x1 + c = %f\" %( a*x1*x1 + b*x1 + c)\n",
- "print \"\\ta*x2*x2 + b*x2 + c = %f\" %( a*x2*x2 + b*x2 + c)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter the coefficients of a quadratic equation:\n",
- " a : 2\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "b : 1\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "c : -3\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The equation is: 2.0 *x*x + 1.0 *x + -3.0 = 0\n",
- "The solutions are:\n",
- "\tx1 = 1.000000\n",
- "\tx2 = -1.500000\n",
- "Check:\n",
- "\ta*x1*x1 + b*x1 + c = 0.000000\n",
- "\ta*x2*x2 + b*x2 + c = 0.000000\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "code",
- "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 "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter float: 234.567e89\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Its reciprocal is: 4.2631742743e-92\n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "# illustrates the scope of variables:\n",
- "x = 11\n",
- "# ERROR: this is not in the scope of x\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",
- " x = 44 # OK: this is in the scope of x\n",
- " y = 55 # OK: this is in the scope of y\n",
- "x = 66 # OK: this is in the scope of x\n",
- "y = 77 # ERROR: this is not in the scope of y\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 17
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "# this x is global\n",
- "x = 11\n",
- "\n",
- "if True:\n",
- " # illustrates the nested and parallel scopes:\n",
- " x = 22\n",
- " # begin scope of internal block\n",
- " if True:\n",
- " x = 33\n",
- " print \"In block inside main(): x = %d \" % x\n",
- " # end scope of internal block\n",
- "print \"In main(): x = %d\" %x \n",
- "print \"In main(): x = %d \"% x"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "In block inside main(): x = 33 \n",
- "In main(): x = 33\n",
- "In main(): x = 33 \n"
- ]
- }
- ],
- "prompt_number": 18
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch3.ipynb b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch3.ipynb
deleted file mode 100644
index 577b8d76..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch3.ipynb
+++ /dev/null
@@ -1,1021 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:0e3c85fb42769559f9f8805f3e4d4314b9161e1f9e7c2177b9fdd0a81efd83fb"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "print \"Enter two positive integers: \";\n",
- "n = int(raw_input())\n",
- "d = int(raw_input())\n",
- "if (n%d):\n",
- " print \"%d is not divisible by %d\" %(n,d)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter two positive integers: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "66\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "7\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "66 is not divisible by 7\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "print \"Enter two positive integers: \";\n",
- "n = int(raw_input())\n",
- "d = int(raw_input())\n",
- "if (n%d):\n",
- " print \"%d is not divisible by %d\" %(n,d)\n",
- "else:\n",
- " print \"%d is divisible by %d\" %(n,d)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter two positive integers: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "56\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "7\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "56 is divisible by 7\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "print \"Enter two integers: \"\n",
- "m = int(raw_input())\n",
- "n = int(raw_input())\n",
- "\n",
- "if (m < n):\n",
- " print \"%d is the minimum.\" %m\n",
- "else:\n",
- " print \"%d is the minimum.\" %n\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter two integers: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "77\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "55\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "55 is the minimum.\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "print \"Enter an integer: \"\n",
- "n = int(raw_input())\n",
- "if (n = 22):\n",
- " print \"%d = 22\" %n\n",
- "else: \n",
- " print \"%d != 22\" %n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "ename": "SyntaxError",
- "evalue": "invalid syntax (<ipython-input-4-d2cee3e182b1>, line 7)",
- "output_type": "pyerr",
- "traceback": [
- "\u001b[1;36m File \u001b[1;32m\"<ipython-input-4-d2cee3e182b1>\"\u001b[1;36m, line \u001b[1;32m7\u001b[0m\n\u001b[1;33m if (n = 22):\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "print \"Enter three integers: \"\n",
- "n1 = int(raw_input())\n",
- "n2 = int(raw_input())\n",
- "n3 = int(raw_input())\n",
- "\n",
- "m=n1\n",
- "# now min <= n1\n",
- "if (n2 < m):\n",
- " m = n2 # now min <= n1 and min <= n2\n",
- "if (n3 < m):\n",
- " m = n3 # now min <= n1, min <= n2, and min <= n3\n",
- "print \"Their minimum is %d\" % m"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter three integers: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "77\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "33\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "55\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Their minimum is 33\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "print \"Enter two integers: \"\n",
- "x = int(raw_input())\n",
- "y = int(raw_input())\n",
- "\n",
- "if (x > y):\n",
- " temp=x\n",
- " x = y\n",
- " y = temp\n",
- " \n",
- "\n",
- "print \"%d <= %d\" %(x,y)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter two integers: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "66\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "44\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "44 <= 66\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "n=44\n",
- "print \"n = %d\" % n \n",
- "if True:\n",
- " # scope extends over 4 lines\n",
- " print \"Enter an integer: \"\n",
- " n = int(raw_input())\n",
- " print \"n = %d\" % n \n",
- "\n",
- "if True:\n",
- " print \"n = %d\" % n \n",
- " # the n that was declared first\n",
- "if True:\n",
- " print \"n = %d\" % n \n",
- "\n",
- "print \"n = %d\" % n "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "n = 44\n",
- "Enter an integer: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "77\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "n = 77\n",
- "n = 77\n",
- "n = 77\n",
- "n = 77\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "print \"Enter three integers: \"\n",
- "n1 = int(raw_input())\n",
- "n2 = int(raw_input())\n",
- "n3 = int(raw_input())\n",
- "if (n1 <= n2 and n1 <= n3):\n",
- " print \"Their minimum is %d\" % n1\n",
- " \n",
- "if (n2 <= n1 and n2 <= n3):\n",
- " print \"Their minimum is %d \" % n2 \n",
- "if (n3 <= n1 and n3 <= n2):\n",
- " print \"Their minimum is %d\" % n3 \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter three integers: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "77\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "33\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "55\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Their minimum is 33 \n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "print \"Are you enrolled (y/n): \"\n",
- "ans = raw_input()\n",
- "if (ans == 'Y' or ans == 'y'):\n",
- " print \"You are enrolled.\\n\"\n",
- "else: \n",
- " print \"You are not enrolled.\\n\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Are you enrolled (y/n): \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "y\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "You are enrolled.\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "print \"Enter two positive integers: \";\n",
- "n = int(raw_input())\n",
- "d = int(raw_input())\n",
- "\n",
- "if (d != 0 and n%d == 0): \n",
- " print \"%d divides %d\" %(d,n)\n",
- "else:\n",
- " print \"%d does not divide %d\"% (d,n)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter two positive integers: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "33\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "6\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "6 does not divide 33\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "print \"Enter three integers: \"\n",
- "n1 = int(raw_input())\n",
- "n2 = int(raw_input())\n",
- "n3 = int(raw_input())\n",
- "\n",
- "if (n1 >= n2 >= n3):\n",
- " print \"max = x\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter three integers: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "1\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "print \"Enter two positive integers: \"\n",
- "n = int(raw_input())\n",
- "d = int(raw_input())\n",
- "\n",
- "if (d != 0):\n",
- " if (n%d == 0):\n",
- " print d,\n",
- " print \" divides %d\" % n \n",
- " else:\n",
- " print \"%d does not divide %d\" %(d,n)\n",
- "else:\n",
- " print '%d does not divide %d '%(d,n)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter two positive integers: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "55\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "44\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "44 does not divide 55\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "print \"Enter three integers: \"\n",
- "n1 = int(raw_input())\n",
- "n2 = int(raw_input())\n",
- "n3 = int(raw_input())\n",
- "if (n1 < n2):\n",
- " if (n1 < n3):\n",
- " print \"Their minimum is : %d\" % n1\n",
- " else:\n",
- " print \"Their minimum is : %d\" % n3\n",
- "else: # n1 >= n2\n",
- " if (n2 < n3):\n",
- " print \"Their minimum is : %d\" % n2\n",
- " else:\n",
- " print \"Their minimum is %d\" % n3"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter three integers: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "77\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "33\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "55\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Their minimum is : 33\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "print \"Pick a number from 1 to 8.\" \n",
- "answer = int(raw_input())\n",
- "print \"Is it less than 5? (y|n): \"\n",
- "answer = raw_input()\n",
- "if (answer == 'y'): # 1 <= n <= 4\n",
- " print \"Is it less than 3? (y|n): \"\n",
- " answer = raw_input() \n",
- " if (answer == 'y'): # 1 <= n <= 2\n",
- " print \"Is it less than 2? (y|n): \"\n",
- " answer = raw_input()\n",
- " if (answer == 'y'):\n",
- " print \"Your number is 1.\"\n",
- " else:\n",
- " print \"Your number is 2.\"\n",
- " else: # 3 <= n <= 4\n",
- " print \"Is it less than 4? (y|n): \"\n",
- " answer = raw_input()\n",
- " if (answer == 'y'):\n",
- " print \"Your number is 3.\"\n",
- " else:\n",
- " print \"Your number is 4.\"\n",
- "else: # 5 <= n <= 8\n",
- " print \"Is it less than 7? (y|n): \"\n",
- " answer = raw_input()\n",
- " if (answer == 'y'): # 5 <= n <= 6\n",
- " print \"Is it less than 6? (y|n): \"\n",
- " answer = raw_input()\n",
- " if (answer == 'y'):\n",
- " print \"Your number is 5.\"\n",
- " else:\n",
- " print \"Your number is 6.\" \n",
- " else: # 7 <= n <= 8\n",
- " print \"Is it less than 8? (y|n): \"\n",
- " answer = raw_input()\n",
- " if (answer == 'y'):\n",
- " print \"Your number is 7.\" \n",
- " else:\n",
- " print \"Your number is 8.\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Pick a number from 1 to 8.\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "6\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Is it less than 5? (y|n): \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "n\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Is it less than 7? (y|n): \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "y\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Is it less than 6? (y|n): \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "n\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Your number is 6.\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "language = raw_input(\"Engl., Fren., Ger., Ital., or Rus.? (e|f|g|i|r): \")\n",
- "\n",
- "if (language == 'e'): \n",
- " print \"Welcome to ProjectEuclid.\"\n",
- "elif (language == 'f'):\n",
- " print \"Bon jour, ProjectEuclid.\"\n",
- "elif (language == 'g'):\n",
- " print \"Guten tag, ProjectEuclid.\"\n",
- "elif (language == 'i'):\n",
- " print \"Bon giorno, ProjectEuclid.\"\n",
- "elif (language == 'r'):\n",
- " print \"Dobre utre, ProjectEuclid.\"\n",
- "else:\n",
- " print \"Sorry; we don't speak your language.\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Engl., Fren., Ger., Ital., or Rus.? (e|f|g|i|r): i\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Bon giorno, ProjectEuclid.\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "score = int(raw_input(\"Enter your test score: \"))\n",
- "a = int(score/10)\n",
- "if a == 10 or a == 9:\n",
- " print \"Your grade is an A.\"\n",
- "elif a == 8:\n",
- " print \"Your grade is a B.\" \n",
- "elif a == 7:\n",
- " print \"Your grade is a C.\" \n",
- "elif a == 6:\n",
- " print \"Your grade is a D.\"\n",
- "elif a==5 or a==4 or a==3 or a==2 or a==1 or a==0:\n",
- " print \"Your grade is an F.\" \n",
- "else:\n",
- " print \"Error: score is out of range.\\n\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter your test score: 83\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Your grade is a B.\n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "score = int(raw_input(\"Enter your test score: \"))\n",
- "a = int(score/10)\n",
- "if a == 10 or a == 9:\n",
- " print \"Your grade is an A.\"\n",
- "elif a == 8:\n",
- " print \"Your grade is a B.\" \n",
- "elif a == 7:\n",
- " print \"Your grade is a C.\" \n",
- "elif a == 6:\n",
- " print \"Your grade is a D.\"\n",
- "elif a==5 or a==4 or a==3 or a==2 or a==1 or a==0:\n",
- " print \"Your grade is an F.\" \n",
- "else:\n",
- " print \"Error: score is out of range.\\n\"\n",
- "\n",
- "print \"Goodbye.\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter your test score: 83\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Your grade is a B.\n",
- "Goodbye.\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "score = int(raw_input(\"Enter your test score: \"))\n",
- "a = int(score/10)\n",
- "if a == 10 or a == 9:\n",
- " print \"Your grade is an A.\"\n",
- "elif a == 8:\n",
- " print \"Your grade is a B.\" \n",
- "elif a == 7:\n",
- " print \"Your grade is a C.\" \n",
- "elif a == 6:\n",
- " print \"Your grade is a D.\"\n",
- "elif a==5 or a==4 or a==3 or a==2 or a==1 or a==0:\n",
- " print \"Your grade is an F.\" \n",
- "else:\n",
- " print \"Error: score is out of range.\\n\"\n",
- "\n",
- "print \"Goodbye.\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter your test score: 83\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Your grade is a B.\n",
- "Goodbye.\n"
- ]
- }
- ],
- "prompt_number": 18
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "print \"Enter two integers: \"\n",
- "m = int(raw_input())\n",
- "n = int(raw_input())\n",
- "print min(m,n),\n",
- "print 'is the minimum'"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter two integers: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "33\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "55\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "33 is the minimum\n"
- ]
- }
- ],
- "prompt_number": 19
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch4.ipynb b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch4.ipynb
deleted file mode 100644
index 80faf7b0..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch4.ipynb
+++ /dev/null
@@ -1,1486 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:151156e7bea70740a97337b774930eddac369834b8935c55926007a1955d4c91"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "i=1\n",
- "print \"Enter a positive integer: \"\n",
- "n = int(raw_input())\n",
- "s=0\n",
- "while (i <= n):\n",
- " s += i\n",
- " i += 1\n",
- "print \"The sum of the first %d integers is %d\" %(i,s)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a positive integer: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "5\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The sum of the first 6 integers is 15\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "print \"Enter a positive integer: \"\n",
- "bound = int(raw_input())\n",
- "s=0.0\n",
- "i=0\n",
- "while (s < bound):\n",
- " i += 1\n",
- " s += 1.0/i\n",
- "\n",
- "print \"The sum of the first %d reciprocals is %f\" %(i,s)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a positive integer: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "5\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The sum of the first 83 reciprocals is 5.002068\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "print \"Enter a positive number: \"\n",
- "x = float(raw_input())\n",
- "while (x > 0):\n",
- " print \"sqrt(%d) = %f \"%(x,math.sqrt(x))\n",
- " print \"Enter another positive number (or 0 to quit): \"\n",
- " x = float(raw_input())\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a positive number: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "5\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "sqrt(5) = 2.236068 \n",
- "Enter another positive number (or 0 to quit): \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "3\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "sqrt(3) = 1.732051 \n",
- "Enter another positive number (or 0 to quit): \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "i=1\n",
- "print \"Enter a positive integer: \";\n",
- "n = int(raw_input())\n",
- "s=0\n",
- "while(True):\n",
- " if (i > n):\n",
- " break # terminates the loop immediately\n",
- " s += i\n",
- " i += 1\n",
- "print \"The sum of the first %d integers is %d\" %(n,s)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a positive integer: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "5\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The sum of the first 5 integers is 15\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "print \"Enter a positive integer: \"\n",
- "bound = int(raw_input())\n",
- "print \"Fibonacci numbers < %d:\\n0, 1\" % bound ,\n",
- "f0=0\n",
- "f1=1\n",
- "while (True):\n",
- " f2 = f0 + f1\n",
- " if (f2 > bound):\n",
- " break\n",
- " print \", %d\" % f2,\n",
- " f0 = f1\n",
- " f1 = f2\n",
- " "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a positive integer: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "10\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Fibonacci numbers < 10:\n",
- "0, 1 , 1 , 2 , 3 , 5 , 8\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import sys\n",
- "print \"Enter a positive integer: \"\n",
- "bound = int(raw_input())\n",
- "print \"Fibonacci numbers < %d:\\n0, 1\" % bound ,\n",
- "f0=0\n",
- "f1=1\n",
- "while (True):\n",
- " f2 = f0 + f1\n",
- " if (f2 > bound):\n",
- " sys.exit(0)\n",
- " print \", %d\" % f2,\n",
- " f0 = f1\n",
- " f1 = f2\n",
- " "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a positive integer: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "10\n"
- ]
- },
- {
- "ename": "SystemExit",
- "evalue": "0",
- "output_type": "pyerr",
- "traceback": [
- "An exception has occurred, use %tb to see the full traceback.\n",
- "\u001b[1;31mSystemExit\u001b[0m\u001b[1;31m:\u001b[0m 0\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Fibonacci numbers < 10:\n",
- "0, 1 , 1 , 2 , 3 , 5 , 8"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stderr",
- "text": [
- "To exit: use 'exit', 'quit', or Ctrl-D.\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "print \"Enter a positive integer: \"\n",
- "bound = int(raw_input())\n",
- "print \"Fibonacci numbers < %d:\\n0, 1\" % bound ,\n",
- "f0=0\n",
- "f1=1\n",
- "# Error : infinite loop !\n",
- "while (True):\n",
- " f2 = f0 + f1\n",
- " # By commenting the below if statement, it goes to infinite.\n",
- " if (f2 > bound):\n",
- " break\n",
- " print \", %d\" % f2,\n",
- " f0 = f1\n",
- " f1 = f2"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a positive integer: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "10\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Fibonacci numbers < 10:\n",
- "0, 1 , 1 , 2 , 3 , 5 , 8\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "print \"Enter a positive integer: \"\n",
- "bound = int(raw_input())\n",
- "print \"Fibonacci numbers < %d:\\n0, 1\" % bound ,\n",
- "f0=0\n",
- "f1=1\n",
- "# Error : infinite loop !\n",
- "while (True):\n",
- " f2 = f0 + f1\n",
- " # By commenting the below if statement, it goes to infinite.\n",
- " if (f2 > bound):\n",
- " break\n",
- " print \", %d\" % f2,\n",
- " f0 = f1\n",
- " f1 = f2"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a positive integer: \n",
- "Fibonacci numbers < 10:\n",
- "0, 1 , 1 , 2 , 3 , 5 , 8\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "i=0\n",
- "print \"Enter a positive integer: \"\n",
- "n = int(raw_input())\n",
- "s=0\n",
- "while i<=n:\n",
- " s += i\n",
- " i += 1\n",
- "print \"The sum of the first %d integers is %d\" %(n,s)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a positive integer: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "10\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The sum of the first 10 integers is 55\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "print \"Enter a positive integer: \"\n",
- "bound = int(raw_input())\n",
- "print \"Factorial numbers < %d:\\n1, 1\" %bound,\n",
- "f=1\n",
- "i=1\n",
- "while f < bound:\n",
- " i += 1\n",
- " f *= i\n",
- " print \", %d\" %f,\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a positive integer: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "10\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Factorial numbers < 10:\n",
- "1, 1 , 2 , 6 , 24\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "print \"Enter a positive integer: \"\n",
- "n = int(raw_input())\n",
- "s=0;\n",
- "for i in range(0,n+1):\n",
- " s += i\n",
- "print \"The sum of the first %d integers is %d\" %(n,s)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a positive integer: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "10\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The sum of the first 10 integers is 55\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "print \"Enter a positive integer: \"\n",
- "n = int(raw_input())\n",
- "s=0\n",
- "for i in range(1,n/2): # the scope of this i is this loop\n",
- " s += i\n",
- "\n",
- "for i in range(n/2,n+1): # the scope of this i is this loop\n",
- " s += i\n",
- "print \"The sum of the first %d integers is %d\" % (n,s)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a positive integer: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "10\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The sum of the first 10 integers is 55\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "print \"Enter a positive integer: \"\n",
- "bound = int(raw_input())\n",
- "\n",
- "print \"Factorial numbers that are <= %d:\\n1, 1\" %bound,\n",
- "f=1\n",
- "for i in range(2,bound+1):\n",
- " f *= i\n",
- " print \", %d\" % f,\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a positive integer: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "10\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Factorial numbers that are <= 10:\n",
- "1, 1 , 2 , 6 , 24 , 120 , 720 , 5040 , 40320 , 362880 , 3628800\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "for i in range(10,0,-1):\n",
- " print i,\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "10 9 8 7 6 5 4 3 2 1\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "prime = True\n",
- "print \"Enter a positive integer: \"\n",
- "n = int(raw_input())\n",
- "if (n < 2):\n",
- " print \"%d is not prime.\" %n\n",
- " prime = False\n",
- "elif (n < 4):\n",
- " print \"%d is prime.\" %n\n",
- " prime = False\n",
- "elif (n%2 == 0):\n",
- " print \"%d = 2* %d\" %(n,n/2)\n",
- " prime = False\n",
- "else:\n",
- " for d in range(3,n/2+1):\n",
- " if (n%d == 0):\n",
- " print \"%d = %d * %d\" %(n,d,n/d)\n",
- " prime = False\n",
- "if prime: \n",
- " print \"%d is prime.\"%n\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a positive integer: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "11\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "11 is prime.\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "print \"Enter positive integers (0 to quit): \";\n",
- "n = int(raw_input())\n",
- "m = n\n",
- "while n > 0:\n",
- " n = int(raw_input())\n",
- " if n > m :\n",
- " m = n\n",
- "\n",
- "print \"max = %d\" % m"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter positive integers (0 to quit): \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "5\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "19\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "42\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "1\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "max = 42\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "print \"Enter positive integers (0 to quit): \";\n",
- "n = int(raw_input())\n",
- "m = n\n",
- "while n > 0: \n",
- " if n < m :\n",
- " m = n\n",
- " n = int(raw_input())\n",
- "\n",
- "print \"min = %d\" % m\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter positive integers (0 to quit): \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "5\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "19\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "42\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "1\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "min = 1\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "m = 95\n",
- "n = 11\n",
- "while m%n > 0:\n",
- " print \"%d modulo %d = %d\" %(m,n,m%n)\n",
- " m -= 3\n",
- " n += 1\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "95 modulo 11 = 7\n",
- "92 modulo 12 = 8\n",
- "89 modulo 13 = 11\n",
- "86 modulo 14 = 2\n",
- "83 modulo 15 = 8\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "for x in range(1,13):\n",
- " for y in range(1,13):\n",
- " print \"%4d\" % (x*y),\n",
- " print \"\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1 2 3 4 5 6 7 8 9 10 11 12 \n",
- " 2 4 6 8 10 12 14 16 18 20 22 24 \n",
- " 3 6 9 12 15 18 21 24 27 30 33 36 \n",
- " 4 8 12 16 20 24 28 32 36 40 44 48 \n",
- " 5 10 15 20 25 30 35 40 45 50 55 60 \n",
- " 6 12 18 24 30 36 42 48 54 60 66 72 \n",
- " 7 14 21 28 35 42 49 56 63 70 77 84 \n",
- " 8 16 24 32 40 48 56 64 72 80 88 96 \n",
- " 9 18 27 36 45 54 63 72 81 90 99 108 \n",
- " 10 20 30 40 50 60 70 80 90 100 110 120 \n",
- " 11 22 33 44 55 66 77 88 99 110 121 132 \n",
- " 12 24 36 48 60 72 84 96 108 120 132 144 \n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "# defines pow() and log()\n",
- "\n",
- "print \"Enter a positive integer: \"\n",
- "n = int(raw_input())\n",
- "d=0 # the discrete binary logarithm of n\n",
- "p2d=1 # = 2^d\n",
- "i = n\n",
- "while i > 1:\n",
- " # INVARIANT: 2^d <= n/i < 2*2^d\n",
- " p2d=math.pow(2,d) # = 2^d\n",
- " print \"%2d <= %2d\" %(p2d,2*p2d)\n",
- " i /= 2\n",
- " d += 1\n",
- "\n",
- "p2d=math.pow(2,d) # = 2^d\n",
- "print \"%2d <= %2d < %2d\" %(p2d,n,2*p2d)\n",
- "print \" The discrete binary logarithm of is %d\" % d \n",
- "lgn = math.log(n)/math.log(2) # base 2 logarithm\n",
- "print \"The continuous binary logarithm of is %f\" % lgn"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a positive integer: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "17\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1 <= 2\n",
- " 2 <= 4\n",
- " 4 <= 8\n",
- " 8 <= 16\n",
- "16 <= 17 < 32\n",
- " The discrete binary logarithm of is 4\n",
- "The continuous binary logarithm of is 4.087463\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "i=1\n",
- "print \"Enter a positive integer: \"\n",
- "n = int(raw_input())\n",
- "s=0\n",
- "while (True):\n",
- " if (i > n):\n",
- " break\n",
- " s += i\n",
- " i += 1\n",
- "\n",
- "print \"The sum of the first %d integers is %d\" %(i,s)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a positive integer: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "10\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The sum of the first 11 integers is 55\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "count=0\n",
- "s=0\n",
- "print \"Enter positive integers (0 to quit):\" \n",
- "while True: # \"forever\"\n",
- " print \"\\t %d :\" %(count + 1),\n",
- " n = int(raw_input())\n",
- " if (n <= 0):\n",
- " break\n",
- " count += 1\n",
- " s += n\n",
- "\n",
- "print \"The average of those %d positive numbers is \" %count,\n",
- "print float(s)/count\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter positive integers (0 to quit):\n",
- "\t 1 :"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "12\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " \t 2 :"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "32\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " \t 3 :"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "11\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " \t 4 :"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The average of those 3 positive numbers is 18.3333333333\n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "for x in range(1,13):\n",
- " for y in range(1,13):\n",
- " if y>x:\n",
- " break\n",
- " else:\n",
- " print '%4d' %(x*y),\n",
- " print ''\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 1 \n",
- " 2 4 \n",
- " 3 6 9 \n",
- " 4 8 12 16 \n",
- " 5 10 15 20 25 \n",
- " 6 12 18 24 30 36 \n",
- " 7 14 21 28 35 42 49 \n",
- " 8 16 24 32 40 48 56 64 \n",
- " 9 18 27 36 45 54 63 72 81 \n",
- " 10 20 30 40 50 60 70 80 90 100 \n",
- " 11 22 33 44 55 66 77 88 99 110 121 \n",
- " 12 24 36 48 60 72 84 96 108 120 132 144 \n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "while True:\n",
- " n = int(raw_input('Enter int : '))\n",
- " if (n%2 == 0):\n",
- " continue\n",
- " if (n%3 == 0):\n",
- " break\n",
- " print \"\\tBottom of loop.\\n\"\n",
- "print \"\\tOutside of loop.\\n\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter int : 5\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\tBottom of loop.\n",
- "\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter int : 4\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter int : 6\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter int : 9\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\tOutside of loop.\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 18
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "N=5\n",
- "done=False\n",
- "for i in range(N):\n",
- " for j in range(N):\n",
- " if done:\n",
- " break\n",
- " for k in range(N):\n",
- " if done:\n",
- " break\n",
- " if (i+j+k>N):\n",
- " done = True\n",
- " else:\n",
- " print i+j+k,\n",
- " print \" \",\n",
- " print \"* \"\n",
- " print \".\" \n",
- " done = False\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0 1 2 3 4 * \n",
- "1 2 3 4 5 * \n",
- "2 3 4 5 * \n",
- ".\n",
- "1 2 3 4 5 * \n",
- "2 3 4 5 * \n",
- ".\n",
- "2 3 4 5 * \n",
- ".\n",
- "3 4 5 * \n",
- ".\n",
- "4 5 * \n",
- ".\n"
- ]
- }
- ],
- "prompt_number": 19
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "N=5\n",
- "done=False\n",
- "for i in range(N):\n",
- " for j in range(N):\n",
- " if done:\n",
- " break\n",
- " for k in range(N):\n",
- " if done:\n",
- " break\n",
- " if (i+j+k>N):\n",
- " done = True\n",
- " else:\n",
- " print i+j+k,\n",
- " print \" \",\n",
- " print \"* \"\n",
- " print \".\" \n",
- " done = False\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0 1 2 3 4 * \n",
- "1 2 3 4 5 * \n",
- "2 3 4 5 * \n",
- ".\n",
- "1 2 3 4 5 * \n",
- "2 3 4 5 * \n",
- ".\n",
- "2 3 4 5 * \n",
- ".\n",
- "3 4 5 * \n",
- ".\n",
- "4 5 * \n",
- ".\n"
- ]
- }
- ],
- "prompt_number": 20
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import random\n",
- "\n",
- "# prints pseudo-random numbers:\n",
- "\n",
- "for i in range(0,8):\n",
- " print random.random()\n",
- "\n",
- " "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0.702115758628\n",
- "0.969460447904\n",
- "0.409934401112\n",
- "0.700339443791\n",
- "0.093528851602\n",
- "0.132172955687\n",
- "0.0162887279366\n",
- "0.943010713478\n"
- ]
- }
- ],
- "prompt_number": 21
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import random\n",
- "# prints pseudo-random numbers:\n",
- "print \"Enter seed: \"\n",
- "seed = int(raw_input())\n",
- "random.seed(seed);\n",
- "for i in range(0,8):\n",
- " print random.random()\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter seed: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "5\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0.62290169489\n",
- "0.741786989261\n",
- "0.795193565566\n",
- "0.942450283777\n",
- "0.73989857474\n",
- "0.922324996665\n",
- "0.0290052282836\n",
- "0.465622654378\n"
- ]
- }
- ],
- "prompt_number": 22
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import random\n",
- "for i in range(0,8):\n",
- " print random.random()\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0.943356716998\n",
- "0.648974553137\n",
- "0.900900491751\n",
- "0.113205964653\n",
- "0.469069047782\n",
- "0.24657283262\n",
- "0.543760859236\n",
- "0.573941187928\n"
- ]
- }
- ],
- "prompt_number": 23
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import random\n",
- "print \"Enter minimum and maximum: \"\n",
- "m = int(raw_input())\n",
- "n = int(raw_input())\n",
- "# lowest and highest numbers\n",
- "r = n - m + 1\n",
- "# number of numbers in range\n",
- "for i in range(0,20):\n",
- " j = int(random.random()*100 % r + m)\n",
- " print j,\n",
- " print \" \",\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter minimum and maximum: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "5\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "15\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "6 15 10 8 15 9 7 7 11 6 5 15 14 15 15 15 11 13 14 6 \n"
- ]
- }
- ],
- "prompt_number": 24
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch5.ipynb b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch5.ipynb
deleted file mode 100644
index a10c8e6e..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch5.ipynb
+++ /dev/null
@@ -1,1542 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:507ed1502286b7e07eb64a51dd0502249f2763079a23aefef815ad5e65c327ad"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "\n",
- "# tests the sqrt() function:\n",
- "for i in range(0,6):\n",
- " print \"\\t %d \\t %f\" %(i,math.sqrt(i))"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\t 0 \t 0.000000\n",
- "\t 1 \t 1.000000\n",
- "\t 2 \t 1.414214\n",
- "\t 3 \t 1.732051\n",
- "\t 4 \t 2.000000\n",
- "\t 5 \t 2.236068\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "# tests the identity sin 2x = 2 sin x cos x:\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",
- " x += 0.2\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0.000000 \t\t 0.000000 \t 0.000000\n",
- "0.200000 \t\t 0.389418 \t 0.389418\n",
- "0.400000 \t\t 0.717356 \t 0.717356\n",
- "0.600000 \t\t 0.932039 \t 0.932039\n",
- "0.800000 \t\t 0.999574 \t 0.999574\n",
- "1.000000 \t\t 0.909297 \t 0.909297\n",
- "1.200000 \t\t 0.675463 \t 0.675463\n",
- "1.400000 \t\t 0.334988 \t 0.334988\n",
- "1.600000 \t\t -0.058374 \t -0.058374\n",
- "1.800000 \t\t -0.442520 \t -0.442520\n",
- "2.000000 \t\t -0.756802 \t -0.756802\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def cube(x):\n",
- " # returns cube of x:\n",
- " return x*x*x\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 3
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def cube(x):\n",
- " # returns cube of x:\n",
- " return x*x*x\n",
- "\n",
- "# tests the cube() function:\n",
- "n=1\n",
- "while (n != 0):\n",
- " n = int(raw_input())\n",
- " print \"\\tcube( %d ) = %d\" %(n,cube(n))"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "4\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\tcube( 4 ) = 64\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "2\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\tcube( 2 ) = 8\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "9\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\tcube( 9 ) = 729\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\tcube( 0 ) = 0\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def maximum(x,y):\n",
- " # returns larger of the two given integers:\n",
- " if (x < y):\n",
- " return y\n",
- " else:\n",
- " return x\n",
- "\n",
- "# tests the max() function:\n",
- "m = 1\n",
- "n = 1\n",
- "while m != 0: \n",
- " m = int(raw_input())\n",
- " n = int(raw_input())\n",
- " print \"\\tmax( %d , %d ) = %d\" %(m,n,maximum(m,n))\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "5\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "2\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\tmax( 5 , 2 ) = 5\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "3\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\tmax( 0 , 3 ) = 3\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def maximum(x,y):\n",
- " # returns larger of the two given integers:\n",
- " if (x < y):\n",
- " return y\n",
- " else:\n",
- " return x\n",
- "\n",
- "# tests the max() function:\n",
- "m = 1\n",
- "n = 1\n",
- "while m != 0: \n",
- " m = int(raw_input())\n",
- " n = int(raw_input())\n",
- " print \"\\tmax( %d , %d ) = %d\" %(m,n,maximum(m,n))\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "5\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "2\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\tmax( 5 , 2 ) = 5\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "3\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\tmax( 0 , 3 ) = 3\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "# returns larger of the two given integers:\n",
- "\n",
- "m = 1\n",
- "n = 1\n",
- "while m!=0:\n",
- " m = int(raw_input())\n",
- " n = int(raw_input())\n",
- " print \"\\tmax(%d,%d) = %d\" %(m,n, max(m,n))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "5\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "4\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\tmax(5,4) = 5\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "4\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "3\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\tmax(4,3) = 4\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "8\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\tmax(8,0) = 8\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "5\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\tmax(0,5) = 5\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def fact(n):\n",
- " if (n < 0):\n",
- " return 0\n",
- " f = 1\n",
- " while (n > 1):\n",
- " f *= n\n",
- " n -= 1\n",
- " return f\n",
- "\n",
- "for i in range(-1,6):\n",
- " print fact(i),\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0 1 1 2 6 24 120\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def fact(n):\n",
- " if (n < 0):\n",
- " return 0\n",
- " f = 1\n",
- " while (n > 1):\n",
- " f *= n\n",
- " n -= 1\n",
- " return f\n",
- "\n",
- "\n",
- "def perm(n,k):\n",
- " # returns P(n,k), the number of permutations of k from n:\n",
- " if (n < 0 or k < 0 or k > n):\n",
- " return 0\n",
- " return fact(n)/fact(n-k)\n",
- "\n",
- "for i in range(-1,8):\n",
- " for j in range(-1,i+2):\n",
- " print perm(i,j),\n",
- " print ''\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0 0 \n",
- "0 1 0 \n",
- "0 1 1 0 \n",
- "0 1 2 2 0 \n",
- "0 1 3 6 6 0 \n",
- "0 1 4 12 24 24 0 \n",
- "0 1 5 20 60 120 120 0 \n",
- "0 1 6 30 120 360 720 720 0 \n",
- "0 1 7 42 210 840 2520 5040 5040 0 \n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def printDate(m,d,y):\n",
- " # prints the given date in literal form:\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",
- " if m == 1:\n",
- " print \"January \",\n",
- " elif m ==2:\n",
- " print \"February \",\n",
- " elif m==3 :\n",
- " print \"March \",\n",
- " elif m==4:\n",
- " print \"April \",\n",
- " elif m==5:\n",
- " print \"May \",\n",
- " elif m==6:\n",
- " print \"June \",\n",
- " elif m==7:\n",
- " print \"July \",\n",
- " elif m==8:\n",
- " print \"August \",\n",
- " elif m==9:\n",
- " print \"September \",\n",
- " elif m==10:\n",
- " print \"October \",\n",
- " elif m==1:\n",
- " print \"November \",\n",
- " else:\n",
- " print \"December \",\n",
- " print d , \", \", y \n",
- "\n",
- "# tests the printDate() function:\n",
- "month = 1\n",
- "while month > 0:\n",
- " month = int(raw_input())\n",
- " day = int(raw_input())\n",
- " year = int(raw_input())\n",
- " printDate(month,day,year)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "9\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "12\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "1989\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "September 12 , 1989\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "5\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "2001\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Error: parameter out of range.\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import string\n",
- "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",
- " print \"The character [\" + c + \"] is a \",\n",
- " if(c.isdigit()):\n",
- " print \"digit.\\n\"\n",
- " elif (c.islower()):\n",
- " print \"lower-case letter.\\n\"\n",
- " elif (c.isupper()): \n",
- " print \"capital letter.\\n\"\n",
- " elif (c.isspace()):\n",
- " print \"white space character.\\n\"\n",
- " elif (ord(c) >= 10 and ord(c) <= 15 or ord(c) == 0):\n",
- " print \"control character.\\n\"\n",
- " elif (ispunct(c)):\n",
- " print \"punctuation mark.\\n\"\n",
- " else:\n",
- " print \"Error.\\n\"\n",
- "\n",
- "# prints the category to which the given character belongs;\n",
- "# tests the printCharCategory() function:\n",
- "for c in range(128):\n",
- " printCharCategory(chr(c))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The character [\u0000] is a control character.\n",
- "\n",
- "The character [\u0001] is a Error.\n",
- "\n",
- "The character [\u0002] is a Error.\n",
- "\n",
- "The character [\u0003] is a Error.\n",
- "\n",
- "The character [\u0004] is a Error.\n",
- "\n",
- "The character [\u0005] is a Error.\n",
- "\n",
- "The character [\u0006] is a Error.\n",
- "\n",
- "The character [\u0007] is a Error.\n",
- "\n",
- "The character [\b] is a Error.\n",
- "\n",
- "The character [\t] is a white space character.\n",
- "\n",
- "The character [\n",
- "] is a white space character.\n",
- "\n",
- "The character [\u000b",
- "] is a white space character.\n",
- "\n",
- "The character [\f",
- "] is a white space character.\n",
- "\n",
- "The character [\r",
- "] is a white space character.\n",
- "\n",
- "The character [\u000e] is a control character.\n",
- "\n",
- "The character [\u000f] is a control character.\n",
- "\n",
- "The character [\u0010] is a Error.\n",
- "\n",
- "The character [\u0011] is a Error.\n",
- "\n",
- "The character [\u0012] is a Error.\n",
- "\n",
- "The character [\u0013] is a Error.\n",
- "\n",
- "The character [\u0014] is a Error.\n",
- "\n",
- "The character [\u0015] is a Error.\n",
- "\n",
- "The character [\u0016] is a Error.\n",
- "\n",
- "The character [\u0017] is a Error.\n",
- "\n",
- "The character [\u0018] is a Error.\n",
- "\n",
- "The character [\u0019] is a Error.\n",
- "\n",
- "The character [\u001a] is a Error.\n",
- "\n",
- "The character [\u001b] is a Error.\n",
- "\n",
- "The character [\u001c",
- "] is a Error.\n",
- "\n",
- "The character [\u001d",
- "] is a Error.\n",
- "\n",
- "The character [\u001e",
- "] is a Error.\n",
- "\n",
- "The character [\u001f] is a Error.\n",
- "\n",
- "The character [ ] is a white space character.\n",
- "\n",
- "The character [!] is a punctuation mark.\n",
- "\n",
- "The character [\"] is a punctuation mark.\n",
- "\n",
- "The character [#] is a punctuation mark.\n",
- "\n",
- "The character [$] is a punctuation mark.\n",
- "\n",
- "The character [%] is a punctuation mark.\n",
- "\n",
- "The character [&] is a punctuation mark.\n",
- "\n",
- "The character ['] is a punctuation mark.\n",
- "\n",
- "The character [(] is a punctuation mark.\n",
- "\n",
- "The character [)] is a punctuation mark.\n",
- "\n",
- "The character [*] is a punctuation mark.\n",
- "\n",
- "The character [+] is a punctuation mark.\n",
- "\n",
- "The character [,] is a punctuation mark.\n",
- "\n",
- "The character [-] is a punctuation mark.\n",
- "\n",
- "The character [.] is a punctuation mark.\n",
- "\n",
- "The character [/] is a punctuation mark.\n",
- "\n",
- "The character [0] is a digit.\n",
- "\n",
- "The character [1] is a digit.\n",
- "\n",
- "The character [2] is a digit.\n",
- "\n",
- "The character [3] is a digit.\n",
- "\n",
- "The character [4] is a digit.\n",
- "\n",
- "The character [5] is a digit.\n",
- "\n",
- "The character [6] is a digit.\n",
- "\n",
- "The character [7] is a digit.\n",
- "\n",
- "The character [8] is a digit.\n",
- "\n",
- "The character [9] is a digit.\n",
- "\n",
- "The character [:] is a punctuation mark.\n",
- "\n",
- "The character [;] is a punctuation mark.\n",
- "\n",
- "The character [<] is a punctuation mark.\n",
- "\n",
- "The character [=] is a punctuation mark.\n",
- "\n",
- "The character [>] is a punctuation mark.\n",
- "\n",
- "The character [?] is a punctuation mark.\n",
- "\n",
- "The character [@] is a punctuation mark.\n",
- "\n",
- "The character [A] is a capital letter.\n",
- "\n",
- "The character [B] is a capital letter.\n",
- "\n",
- "The character [C] is a capital letter.\n",
- "\n",
- "The character [D] is a capital letter.\n",
- "\n",
- "The character [E] is a capital letter.\n",
- "\n",
- "The character [F] is a capital letter.\n",
- "\n",
- "The character [G] is a capital letter.\n",
- "\n",
- "The character [H] is a capital letter.\n",
- "\n",
- "The character [I] is a capital letter.\n",
- "\n",
- "The character [J] is a capital letter.\n",
- "\n",
- "The character [K] is a capital letter.\n",
- "\n",
- "The character [L] is a capital letter.\n",
- "\n",
- "The character [M] is a capital letter.\n",
- "\n",
- "The character [N] is a capital letter.\n",
- "\n",
- "The character [O] is a capital letter.\n",
- "\n",
- "The character [P] is a capital letter.\n",
- "\n",
- "The character [Q] is a capital letter.\n",
- "\n",
- "The character [R] is a capital letter.\n",
- "\n",
- "The character [S] is a capital letter.\n",
- "\n",
- "The character [T] is a capital letter.\n",
- "\n",
- "The character [U] is a capital letter.\n",
- "\n",
- "The character [V] is a capital letter.\n",
- "\n",
- "The character [W] is a capital letter.\n",
- "\n",
- "The character [X] is a capital letter.\n",
- "\n",
- "The character [Y] is a capital letter.\n",
- "\n",
- "The character [Z] is a capital letter.\n",
- "\n",
- "The character [[] is a punctuation mark.\n",
- "\n",
- "The character [\\] is a punctuation mark.\n",
- "\n",
- "The character []] is a punctuation mark.\n",
- "\n",
- "The character [^] is a punctuation mark.\n",
- "\n",
- "The character [_] is a punctuation mark.\n",
- "\n",
- "The character [`] is a punctuation mark.\n",
- "\n",
- "The character [a] is a lower-case letter.\n",
- "\n",
- "The character [b] is a lower-case letter.\n",
- "\n",
- "The character [c] is a lower-case letter.\n",
- "\n",
- "The character [d] is a lower-case letter.\n",
- "\n",
- "The character [e] is a lower-case letter.\n",
- "\n",
- "The character [f] is a lower-case letter.\n",
- "\n",
- "The character [g] is a lower-case letter.\n",
- "\n",
- "The character [h] is a lower-case letter.\n",
- "\n",
- "The character [i] is a lower-case letter.\n",
- "\n",
- "The character [j] is a lower-case letter.\n",
- "\n",
- "The character [k] is a lower-case letter.\n",
- "\n",
- "The character [l] is a lower-case letter.\n",
- "\n",
- "The character [m] is a lower-case letter.\n",
- "\n",
- "The character [n] is a lower-case letter.\n",
- "\n",
- "The character [o] is a lower-case letter.\n",
- "\n",
- "The character [p] is a lower-case letter.\n",
- "\n",
- "The character [q] is a lower-case letter.\n",
- "\n",
- "The character [r] is a lower-case letter.\n",
- "\n",
- "The character [s] is a lower-case letter.\n",
- "\n",
- "The character [t] is a lower-case letter.\n",
- "\n",
- "The character [u] is a lower-case letter.\n",
- "\n",
- "The character [v] is a lower-case letter.\n",
- "\n",
- "The character [w] is a lower-case letter.\n",
- "\n",
- "The character [x] is a lower-case letter.\n",
- "\n",
- "The character [y] is a lower-case letter.\n",
- "\n",
- "The character [z] is a lower-case letter.\n",
- "\n",
- "The character [{] is a punctuation mark.\n",
- "\n",
- "The character [|] is a punctuation mark.\n",
- "\n",
- "The character [}] is a punctuation mark.\n",
- "\n",
- "The character [~] is a punctuation mark.\n",
- "\n",
- "The character [\u007f] is a Error.\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import math\n",
- "def isPrime(n):\n",
- " # returns True if n is prime, False otherwise:\n",
- " sqrtn = math.sqrt(n)\n",
- " if (n < 2):\n",
- " return False\n",
- " # 0 and 1 are not primes\n",
- " if (n < 4):\n",
- " return True\n",
- " # 2 and 3 are the first primes\n",
- " if (n%2 == 0):\n",
- " return False\n",
- " # 2 is the only even prime\n",
- " for d in range(3,int(sqrtn+1),2):\n",
- " if (n%d == 0):\n",
- " return False\n",
- " # n has a nontrivial divisor\n",
- " return True;\n",
- "\n",
- "for n in range(0,80):\n",
- " if (isPrime(n)):\n",
- " print n,\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def isLeapYear(y):\n",
- " # returns true iff y is a leap year:\n",
- " return (y % 4 == 0 and y % 100 != 0 or y % 400 == 0)\n",
- "\n",
- "# tests the isLeapYear() function:\n",
- "n = 2\n",
- "while n > 1:\n",
- " n = int(raw_input())\n",
- " if (isLeapYear(n)):\n",
- " print \"%d is a leap year.\" % n\n",
- " else:\n",
- " print \"%d is not a leap year.\" %n\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "2004\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "2004 is a leap year.\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "2006\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "2006 is not a leap year.\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "2013\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "2013 is not a leap year.\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0 is a leap year.\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def age():\n",
- " # prompts the user to input his/her age, and returns that value:\n",
- " while (True):\n",
- " print \"How old are you: \"\n",
- " n = int(raw_input())\n",
- " if (n < 0):\n",
- " print \"\\a\\tYour age could not be negative.\"\n",
- " elif (n > 120):\n",
- " print \"\\a\\tYou could not be over 120.\"\n",
- " else:\n",
- " return n\n",
- " print \"\\n\\tTry again.\\n\"\n",
- "\n",
- "a = age();\n",
- "print \"\\nYou are %d years old.\" %a\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "How old are you: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "-12\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\u0007\tYour age could not be negative.\n",
- "\n",
- "\tTry again.\n",
- "\n",
- "How old are you: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "125\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\u0007\tYou could not be over 120.\n",
- "\n",
- "\tTry again.\n",
- "\n",
- "How old are you: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "24\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "You are 24 years old.\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def swap(x,y):\n",
- " # exchanges the values of x and y:\n",
- " x[0],y[0] = y[0],x[0]\n",
- "\n",
- "a = [22.2]\n",
- "b = [44.4]\n",
- "print \"a = %.2f , b = %.2f \" %(a[0],b[0])\n",
- "swap(a,b)\n",
- "print \"a = %.2f , b = %.2f \" %(a[0],b[0])\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "a = 22.20 , b = 44.40 \n",
- "a = 44.40 , b = 22.20 \n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def f(x,y):\n",
- " 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",
- "f(a,b)\n",
- "print \"a = %.2f , b = %.2f \" %(a[0],b[0])\n",
- "f(2*a,b)\n",
- "print \"a = %.2f , b = %.2f \" %(a[0],b[0])\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "a = 22.00 , b = 44.00 \n",
- "a = 88.00 , b = 99.00 \n",
- "a = 88.00 , b = 99.00 \n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def computeCircle(r):\n",
- " # returns the area and circumference of a circle with radius r:\n",
- " PI = 3.141592653589793\n",
- " area = PI*r*r\n",
- " circumference = 2*PI*r\n",
- " return area,circumference\n",
- "\n",
- "# tests the computeCircle() function:\n",
- "print \"Enter radius: \"\n",
- "r = int(raw_input())\n",
- "a,c = computeCircle(r)\n",
- "print \"area = %.2f , circumference = %.2f\" %(a,c)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter radius: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "5\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "area = 78.54 , circumference = 31.42\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def f(x,y,z):\n",
- " x[0] += z[0]\n",
- " y[0] += z[0]\n",
- " print \"x = %d , y = %d , z = %d\" %(x[0],y[0],z[0])\n",
- "\n",
- "x = [22]\n",
- "y = [33]\n",
- "z = [44]\n",
- "\n",
- "print \"x = %d , y = %d , z = %d\" %(x[0],y[0],z[0])\n",
- "f(x,y,z)\n",
- "print \"x = %d , y = %d , z = %d\" %(x[0],y[0],z[0])\n",
- "x[0] = 2*x[0] - 3\n",
- "f(x,y,z)\n",
- "print \"x = %d , y = %d , z = %d\" %(x[0],y[0],z[0])\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "x = 22 , y = 33 , z = 44\n",
- "x = 66 , y = 77 , z = 44\n",
- "x = 66 , y = 77 , z = 44\n",
- "x = 173 , y = 121 , z = 44\n",
- "x = 173 , y = 121 , z = 44\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def cube(x):\n",
- " # returns cube of x:\n",
- " return x*x*x\n",
- "\n",
- "# tests the cube() function:\n",
- "print cube(4)\n",
- "x = int(raw_input())\n",
- "y = cube(2*x-3)\n",
- "print y\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "64\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "5\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "343\n"
- ]
- }
- ],
- "prompt_number": 19
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "x = 11\n",
- "\n",
- "def f():\n",
- " x = 44\n",
- " print \"In f(): x = %d\" % x \n",
- "\n",
- "def g():\n",
- " print \"In g(): x = %d\" % x \n",
- "\n",
- "x = 22\n",
- "x = 33\n",
- "print \"In block inside main(): x = %d\" % x\n",
- "\n",
- "\n",
- "print \"In main(): x = %d\" % x \n",
- "print \"In main(): ::x = %d\" % x \n",
- "f()\n",
- "g()\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "In block inside main(): x = 33\n",
- "In main(): x = 33\n",
- "In main(): ::x = 33\n",
- "In f(): x = 44\n",
- "In g(): x = 33\n"
- ]
- }
- ],
- "prompt_number": 20
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def max_(x, y,z=0):\n",
- " if x > y and x > y:\n",
- " return x\n",
- " elif y > x and y > z:\n",
- " return y\n",
- " else:\n",
- " return z\n",
- " \n",
- " \n",
- "print max(99,77), \" \" , max(55,66,33)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "99 66\n"
- ]
- }
- ],
- "prompt_number": 21
- },
- {
- "cell_type": "code",
- "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",
- "if (d == 0):\n",
- " import sys\n",
- " sys.exit(0)\n",
- "print n , \"/\" , d , \" = \" , n/d \n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter two integers: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "8\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "2\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "8 / 2 = 4\n"
- ]
- }
- ],
- "prompt_number": 22
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def reciprocal(x):\n",
- " #returns the reciprocal of x:\n",
- " if (x == 0):\n",
- " import sys\n",
- " sys.exit(1); # terminate the program\n",
- " return 1.0/x\n",
- "\n",
- "x = float(raw_input())\n",
- "print reciprocal(x)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "25\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "0.04\n"
- ]
- }
- ],
- "prompt_number": 23
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def p(x,a0,a1=0,a2=0,a3=0):\n",
- " # returns a0 + a1*x + a2*x^2 + a3*x^3:\n",
- " return (a0 + (a1 + (a2 + a3*x)*x)*x)\n",
- "\n",
- "\n",
- "# tests the p() function:\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",
- "print \"p(x,7,6,5) = %f\" % p(x,7,6,5)\n",
- "print \"p(x,7,6,5,4) = %f\" % p(x,7,6,5,4)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "p(x,7) = 7.000000\n",
- "p(x,7,6) = 19.001800\n",
- "p(x,7,6,5) = 39.007800\n",
- "p(x,7,6,5,4) = 71.022203\n"
- ]
- }
- ],
- "prompt_number": 24
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch6.ipynb b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch6.ipynb
deleted file mode 100644
index e1a26f6e..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch6.ipynb
+++ /dev/null
@@ -1,1139 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:a7aedcfda01e5e2719af0a5e76da43c6e7b01797bb61e0483e48a2e68eb0941d"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "a = [0, 0, 0]\n",
- "a[2] = 55.55\n",
- "a[0] = 11.11\n",
- "a[1] = 33.33\n",
- "print \"a[0] = \" , a[0] \n",
- "print \"a[1] = \" , a[1] \n",
- "print \"a[2] = \" , a[2] \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "a[0] = 11.11\n",
- "a[1] = 33.33\n",
- "a[2] = 55.55\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "SIZE=5 # defines the size N for 5 elements\n",
- "a = []\n",
- "# declares the array's elements as type double\n",
- "print \"Enter \" , SIZE , \" numbers:\\t\"\n",
- "for i in range(SIZE):\n",
- " a.append(float(raw_input()))\n",
- " \n",
- "print \"In reverse order: \"\n",
- "for i in range(SIZE-1,-1,-1):\n",
- " print \"\\t\" , a[i]\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter 5 numbers:\t\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "1\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "2\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "3.3\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "4.4\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "5.5\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "In reverse order: \n",
- "\t5.5\n",
- "\t4.4\n",
- "\t3.3\n",
- "\t2.0\n",
- "\t1.0\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "a = [ 22.2, 44.4, 66.6 ]\n",
- "\n",
- "size = len(a)\n",
- "for i in range(size):\n",
- " print \"\\ta[\" , i , \"] = \" , a[i]\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\ta[ 0 ] = 22.2\n",
- "\ta[ 1 ] = 44.4\n",
- "\ta[ 2 ] = 66.6\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "a = [ 22.2, 44.4, 66.6 , 0 ,0,0,0]\n",
- "size = len(a)\n",
- "for i in range(size):\n",
- " print \"\\ta[\" , i , \"] = \" , a[i] \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\ta[ 0 ] = 22.2\n",
- "\ta[ 1 ] = 44.4\n",
- "\ta[ 2 ] = 66.6\n",
- "\ta[ 3 ] = 0\n",
- "\ta[ 4 ] = 0\n",
- "\ta[ 5 ] = 0\n",
- "\ta[ 6 ] = 0\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import numpy\n",
- "SIZE = 4\n",
- "a = numpy.zeros(4)\n",
- "# declares the array's elements as type float\n",
- "for i in range(SIZE):\n",
- " print \"\\ta[\" , i , \"] = \" , a[i]\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\ta[ 0 ] = 0.0\n",
- "\ta[ 1 ] = 0.0\n",
- "\ta[ 2 ] = 0.0\n",
- "\ta[ 3 ] = 0.0\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "SIZE=4\n",
- "a = [ 33.3, 44.4, 55.5, 66.6 ]\n",
- "for i in range(7): # ERROR: index is out of bounds!\n",
- " print \"\\ta[\" , i , \"] = \" , a[i] \n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "ename": "IndexError",
- "evalue": "list index out of range",
- "output_type": "pyerr",
- "traceback": [
- "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mIndexError\u001b[0m Traceback (most recent call last)",
- "\u001b[1;32m<ipython-input-6-248fbb50a5b0>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[0ma\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m \u001b[1;36m33.3\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m44.4\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m55.5\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m66.6\u001b[0m \u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m7\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m \u001b[1;31m# ERROR: index is out of bounds!\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 8\u001b[1;33m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"\\ta[\"\u001b[0m \u001b[1;33m,\u001b[0m \u001b[0mi\u001b[0m \u001b[1;33m,\u001b[0m \u001b[1;34m\"] = \"\u001b[0m \u001b[1;33m,\u001b[0m \u001b[0ma\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 9\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
- "\u001b[1;31mIndexError\u001b[0m: list index out of range"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\ta[ 0 ] = 33.3\n",
- "\ta[ 1 ] = 44.4\n",
- "\ta[ 2 ] = 55.5\n",
- "\ta[ 3 ] = 66.6\n",
- "\ta[ 4 ] = "
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "a = [ 22.2, 44.4, 66.6 ]\n",
- "x=11.1\n",
- "print \"x = \" , x \n",
- "a.append(88.8) # ERROR: index is out of bounds!\n",
- "print \"x = \" , x \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " x = 11.1\n",
- "x = 11.1\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "a = [ 22.2, 44.4, 66.6 ]\n",
- "x=11.1\n",
- "print \"x = \" , x \n",
- "a[3333] = 88.8 # ERROR: index is out of bounds!\n",
- "print \"x = \" , x \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "ename": "IndexError",
- "evalue": "list assignment index out of range",
- "output_type": "pyerr",
- "traceback": [
- "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mIndexError\u001b[0m Traceback (most recent call last)",
- "\u001b[1;32m<ipython-input-8-63b6c8e60294>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m11.1\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"x = \"\u001b[0m \u001b[1;33m,\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 8\u001b[1;33m \u001b[0ma\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m3333\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m88.8\u001b[0m \u001b[1;31m# ERROR: index is out of bounds!\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 9\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"x = \"\u001b[0m \u001b[1;33m,\u001b[0m \u001b[0mx\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
- "\u001b[1;31mIndexError\u001b[0m: list assignment index out of range"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "x = 11.1\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def sum_(a):\n",
- " s = 0\n",
- " for i in a:\n",
- " s += i\n",
- " return s\n",
- " \n",
- "a = [ 11, 33, 55, 77 ]\n",
- "print \"sum(a) = \" , sum_(a) \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "sum(a) = 176\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def read(a):\n",
- " print \"Enter integers. Terminate with 0:\\n\"\n",
- " n = 1\n",
- " while True:\n",
- " n = int(raw_input(\"a[\" + str(len(a)) + \"]: \"))\n",
- " if n == 0:\n",
- " break\n",
- " a.append(n)\n",
- " \n",
- "\n",
- "def print_(a):\n",
- " for i in a:\n",
- " print i ,\n",
- "\n",
- "\n",
- "a = []\n",
- "read(a)\n",
- "print \"The array has \" , len(a) , \" elements: \"\n",
- "print_(a)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter integers. Terminate with 0:\n",
- "\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "a[0]: 11\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "a[1]: 22\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "a[2]: 33\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "a[3]: 44\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "a[4]: 0\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The array has 4 elements: \n",
- "11 22 33 44\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import sys\n",
- "a = [ 22, 44, 66, 88 ]\n",
- "print \"a = \" , id(a) # the address of a[0]\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "a = 169156908\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def index(x,a,n):\n",
- " for i in range(len(a)):\n",
- " if (a[i] == x):\n",
- " return i\n",
- " return n # x not found\n",
- "\n",
- "a = [ 22, 44, 66, 88, 44, 66, 55 ]\n",
- "print \"index(44,a,7) = \" , index(44,a,7)\n",
- "print \"index(50,a,7) = \" , index(50,a,7) \n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "index(44,a,7) = 1\n",
- "index(50,a,7) = 7\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def sort(a,n):\n",
- " # bubble sort:\n",
- " n = len(a)\n",
- " for i in range(n):\n",
- " # bubble up max{a[0..n-i]}:\n",
- " for j in range(n-i-1):\n",
- " if (a[j] > a[j+1]):\n",
- " a[j],a[j+1] = a[j+1],a[j]\n",
- "\n",
- "def print_(a):\n",
- " for i in range(len(a)):\n",
- " print a[i],\n",
- " print ''\n",
- " \n",
- "a = [55.5, 22.5, 99.9, 66.6, 44.4, 88.8, 33.3, 77.7]\n",
- "\n",
- "print_(a)\n",
- "sort(a,8)\n",
- "print_(a)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "55.5 22.5 99.9 66.6 44.4 88.8 33.3 77.7 \n",
- "22.5 33.3 44.4 55.5 66.6 77.7 88.8 99.9 \n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def index(x,a,n):\n",
- " # PRECONDITION: a[0] <= a[1] <= ... <= a[n-1];\n",
- " # binary search:\n",
- " lo=0\n",
- " hi=n-1\n",
- " while (lo <= hi):\n",
- " i = (lo + hi)/2 # the average of lo and hi\n",
- " if (a[i] == x):\n",
- " return i\n",
- " if (a[i] < x):\n",
- " lo = i+1 # continue search in a[i+1..hi]\n",
- " else:\n",
- " hi = i-1 # continue search in a[lo..i-1]\n",
- " return n # x was not found in a[0..n-1]\n",
- "\n",
- "a = [ 22, 33, 44, 55, 66, 77, 88 ]\n",
- "print \"index(44,a,7) = \" , index(44,a,7)\n",
- "print \"index(60,a,7) = \" , index(60,a,7) \n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "index(44,a,7) = 2\n",
- "index(60,a,7) = 7\n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def isNondecreasing(a,n):\n",
- " # returns true iff a[0] <= a[1] <= ... <= a[n-1]:\n",
- " for i in range(1,n):\n",
- " if (a[i]<a[i-1]):\n",
- " return False\n",
- " return True\n",
- "\n",
- "a = [ 22, 44, 66, 88, 44, 66, 55 ]\n",
- "print \"isNondecreasing(a,4) = \" , isNondecreasing(a,4)\n",
- "print \"isNondecreasing(a,7) = \" , isNondecreasing(a,7)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "isNondecreasing(a,4) = True\n",
- "isNondecreasing(a,7) = False\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def isNondecreasing(a,n):\n",
- " # returns true iff a[0] <= a[1] <= ... <= a[n-1]:\n",
- " for i in range(1,n):\n",
- " if (a[i]<a[i-1]):\n",
- " return False\n",
- " return True\n",
- "\n",
- "\n",
- "def index(x,a,n):\n",
- " # PRECONDITION: a[0] <= a[1] <= ... <= a[n-1];\n",
- " # binary search:\n",
- " assert(isNondecreasing(a,n)) \n",
- " \n",
- " lo=0\n",
- " hi=n-1\n",
- " while (lo <= hi):\n",
- " i = (lo + hi)/2\n",
- " if (a[i] == x):\n",
- " return i\n",
- " if (a[i] < x):\n",
- " lo = i+1 # continue search in a[i+1..hi]\n",
- " else:\n",
- " hi = i-1 # continue search in a[lo..i-1]\n",
- " return n # x was not found in a[0..n-1]\n",
- "\n",
- "a = [ 22, 33, 44, 55, 66, 77, 88, 60 ]\n",
- "print \"index(44,a,7) = \" , index(44,a,7) \n",
- "print \"index(44,a,8.py) = \" , index(44,a,8) \n",
- "print \"index(60,a,7) = \" , index(60,a,8)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "ename": "AssertionError",
- "evalue": "",
- "output_type": "pyerr",
- "traceback": [
- "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mAssertionError\u001b[0m Traceback (most recent call last)",
- "\u001b[1;32m<ipython-input-18-3a784dd6b25e>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 34\u001b[0m \u001b[0ma\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m \u001b[1;36m22\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m33\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m44\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m55\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m66\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m77\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m88\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m60\u001b[0m \u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 35\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"index(44,a,7) = \"\u001b[0m \u001b[1;33m,\u001b[0m \u001b[0mindex\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m44\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m7\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 36\u001b[1;33m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"index(44,a,7) = \"\u001b[0m \u001b[1;33m,\u001b[0m \u001b[0mindex\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m44\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m8\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 37\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"index(60,a,7) = \"\u001b[0m \u001b[1;33m,\u001b[0m \u001b[0mindex\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m60\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m8\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
- "\u001b[1;32m<ipython-input-18-3a784dd6b25e>\u001b[0m in \u001b[0;36mindex\u001b[1;34m(x, a, n)\u001b[0m\n\u001b[0;32m 18\u001b[0m \u001b[1;31m# PRECONDITION: a[0] <= a[1] <= ... <= a[n-1];\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 19\u001b[0m \u001b[1;31m# binary search:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 20\u001b[1;33m \u001b[1;32massert\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0misNondecreasing\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mn\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 21\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 22\u001b[0m \u001b[0mlo\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
- "\u001b[1;31mAssertionError\u001b[0m: "
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "index(44,a,7) = 2\n",
- "index(44,a,7) = "
- ]
- }
- ],
- "prompt_number": 18
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "Day = [ 0, 1, 2, 3, 4, 5, 6 ]\n",
- "high = [ 88.3, 95.0, 91.2, 89.9, 91.4, 92.5, 86.7]\n",
- "\n",
- "for i in Day:\n",
- " print \"The high temperature for day \" , i , \" was \" , high[i] \n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The high temperature for day 0 was 88.3\n",
- "The high temperature for day 1 was 95.0\n",
- "The high temperature for day 2 was 91.2\n",
- "The high temperature for day 3 was 89.9\n",
- "The high temperature for day 4 was 91.4\n",
- "The high temperature for day 5 was 92.5\n",
- "The high temperature for day 6 was 86.7\n"
- ]
- }
- ],
- "prompt_number": 19
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def sort(a,n):\n",
- " a.sort()\n",
- "\n",
- "def print_(a,n):\n",
- " for i in a:\n",
- " print i,\n",
- " print ''\n",
- "a = [55.5, 22.5, 99.9, 66.6, 44.4, 88.8, 33.3, 77.7]\n",
- "print_(a,8);\n",
- "sort(a,8)\n",
- "print_(a,8)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "55.5 22.5 99.9 66.6 44.4 88.8 33.3 77.7 \n",
- "22.5 33.3 44.4 55.5 66.6 77.7 88.8 99.9 \n"
- ]
- }
- ],
- "prompt_number": 20
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def read(a):\n",
- " print \"Enter 15 integers, 5 per row:\\n\"\n",
- " for i in range(3):\n",
- " ar = []\n",
- " print \"Row \" , i , \": \",\n",
- " for j in range(5):\n",
- " ar.append(int(raw_input()))\n",
- " a.append(ar)\n",
- "\n",
- "def print_(a):\n",
- " for i in range(3):\n",
- " for j in range(5):\n",
- " print a[i][j],\n",
- " print ''\n",
- "a = []\n",
- "read(a)\n",
- "print_(a)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter 15 integers, 5 per row:\n",
- "\n",
- "Row 0 : "
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "44\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "77\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "33\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "11\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "44\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Row 1 : "
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "60\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "50\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "30\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "90\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "70\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Row 2 : "
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "85\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "25\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "45\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "45\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "55\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 44 77 33 11 44 \n",
- "60 50 30 90 70 \n",
- "85 25 45 45 55 \n"
- ]
- }
- ],
- "prompt_number": 21
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def read(score):\n",
- " for s in range(3):\n",
- " print \"Student \" , s , \": \",\n",
- " st = []\n",
- " for q in range(5):\n",
- " st.append(int(raw_input()))\n",
- " score.append(st)\n",
- "\n",
- "def printQuizAverages(score):\n",
- " for s in range(3):\n",
- " sm = 0\n",
- " for q in range(5):\n",
- " sm += score[s][q]\n",
- " print \"\\tStudent \" , s , \": \" , sm/5.0\n",
- "\n",
- "def printClassAverages(score):\n",
- " for q in range(5):\n",
- " sm = 0\n",
- " for s in range(3):\n",
- " sm += score[s][q]\n",
- " print \"\\tQuiz \" , q , \": \" , sm/3.0\n",
- "\n",
- "\n",
- "\n",
- "NUM_STUDENTS = 3\n",
- "NUM_QUIZZES = 5\n",
- "\n",
- "\n",
- "score = []\n",
- "print \"Enter \" , NUM_QUIZZES , \" scores for each student: \"\n",
- "read(score)\n",
- "print \"The quiz averages are:\"\n",
- "printQuizAverages(score)\n",
- "print \"The class averages are: \"\n",
- "printClassAverages(score)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter 5 scores for each student: \n",
- "Student 0 : "
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "8\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "7\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "9\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "8\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "9\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Student 1 : "
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "9\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "9\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "9\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "9\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "8\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " Student 2 : "
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "5\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "6\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "7\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "8\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "9\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The quiz averages are:\n",
- "\tStudent 0 : 8.2\n",
- "\tStudent 1 : 8.8\n",
- "\tStudent 2 : 7.0\n",
- "The class averages are: \n",
- "\tQuiz 0 : 7.33333333333\n",
- "\tQuiz 1 : 7.33333333333\n",
- "\tQuiz 2 : 8.33333333333\n",
- "\tQuiz 3 : 8.33333333333\n",
- "\tQuiz 4 : 8.66666666667\n"
- ]
- }
- ],
- "prompt_number": 24
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "def numZeros(a,n1,n2,n3):\n",
- " count = 0\n",
- " for i in range(n1):\n",
- " for j in range(n2):\n",
- " for k in range(n3):\n",
- " if (a[i][j][k] == 0):\n",
- " count += 1\n",
- " return count\n",
- "\n",
- "\n",
- "a = [ [ [5,0,2], [0,0,9], [4,1,0], [7,7,7] ],[ [3,0,0], [8,5,0], [0,0,0], [2,0,9] ]]\n",
- "print \"This array has \" , numZeros(a,2,4,3) , \" zeros\"\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "This array has 11 zeros\n"
- ]
- }
- ],
- "prompt_number": 25
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch7.ipynb b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch7.ipynb
deleted file mode 100644
index ad8cdac0..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch7.ipynb
+++ /dev/null
@@ -1,629 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:653231542b6fdffa18c8d3af4f8fe1f2545223a4300162071901adcb77895ba7"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "n=44\n",
- "print \"n = \" , n \n",
- "# prints the value of n\n",
- "print \"&n = \" , hex(id(n)) # prints the address of n\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "n = 44\n",
- "&n = 0x8fc0eec\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "\n",
- "n = [44]\n",
- "rn=n # r is a synonym for n\n",
- "print \"n = \" , n , \", rn = \" , rn \n",
- "n[0] -= 1\n",
- "print \"n = \" , n , \", rn = \" , rn \n",
- "rn[0] *= 2\n",
- "print \"n = \" , n , \", rn = \" , rn \n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "n = [44] , rn = [44]\n",
- "n = [43] , rn = [43]\n",
- "n = [86] , rn = [86]\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "\n",
- "\n",
- "n = [44]\n",
- "rn=n # r is a synonym for n\n",
- "print \"&n = \" , hex(id(n)) , \", rn = \" , hex(id(rn ))\n",
- "rn2 = n\n",
- "rn3 = rn\n",
- "print \"&rn2 = \" , hex(id(rn2)) , \", rn = \" , hex(id(rn ))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "&n = 0x9c6228c , rn = 0x9c6228c\n",
- "&rn2 = 0x9c6228c , rn = 0x9c6228c\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "n = [44]\n",
- "print \"n = \" , n , \", &n = \" , hex(id(n))\n",
- "pn = n\n",
- "print \"pn = \" , hex(id(pn)) , \", &pn = \" , hex(id(hex(id(pn))))\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "n = [44] , &n = 0x9c624ec\n",
- "pn = 0x9c624ec , &pn = 0x9c6aa60\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "n = [44]\n",
- "print \"n = \" , n , \", &n = \" , hex(id(n))\n",
- "pn = n\n",
- "print \"\\tpn = \" , hex(id(pn)) , \",\\n &pn = \" , hex(id(hex(id(pn))))\n",
- "print \"*pn = \" , pn\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "n = [44] , &n = 0x9c58d6c\n",
- "\tpn = 0x9c58d6c ,\n",
- " &pn = 0x9c6ab20\n",
- "*pn = [44]\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "n = [44]\n",
- "print \"n = \" , n , \", &n = \" , hex(id(n))\n",
- "pn = n\n",
- "print \"\\tpn = \" , hex(id(pn)) , \",\\n &pn = \" , hex(id(hex(id(pn))))\n",
- "print \"*pn = \" , pn\n",
- "ppn = pn\n",
- "\n",
- "print \" ppn = \" , hex(id(hex(id(ppn)))) \n",
- "print \" &ppn = \" , hex(id(hex(id(hex(id(ppn))))))\n",
- "print \" *ppn = \" , hex(id(ppn)) \n",
- "print \"**ppn = \" , ppn \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "n = [44] , &n = 0x9bf05ac\n",
- "\tpn = 0x9bf05ac ,\n",
- " &pn = 0x9c58160\n",
- "*pn = [44]\n",
- " ppn = 0x9c58680\n",
- " &ppn = 0x9c58160\n",
- " *ppn = 0x9bf05ac\n",
- "**ppn = [44]\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "n = [44]\n",
- "print \"n = \" , n , \"\\n &n = \" , hex(id(n))\n",
- "pn = n\n",
- "print \"\\tpn = \" , hex(id(pn)) , \",\\n &pn = \" , hex(id(hex(id(pn))))\n",
- "print \"*pn = \" , pn\n",
- "nn = pn\n",
- "print \" ppn = \" , hex(id(nn))\n",
- "print \" &ppn = \" , hex(id(hex(id(nn))))\n",
- "rpn = pn\n",
- "print \" ppn = \" , hex(id(rpn))\n",
- "print \" &ppn = \" , hex(id(hex(id(rpn))))\n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "n = [44] \n",
- " &n = 0x9bf60ec\n",
- "\tpn = 0x9bf60ec ,\n",
- " &pn = 0x9bf0e40\n",
- "*pn = [44]\n",
- " ppn = 0x9bf60ec\n",
- " &ppn = 0x9bf0e40\n",
- " ppn = 0x9bf60ec\n",
- " &ppn = 0x9bf0f20\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "def max_(m,n):\n",
- " if m>n:\n",
- " return m\n",
- " else:\n",
- " return n\n",
- "\n",
- "m = 44\n",
- "n = 22\n",
- "print m , \", \" , n , \", \" , max_(m,n)\n",
- "m = max_(m,n) \n",
- "m = 55\n",
- "# changes the value of m from 44 to 55\n",
- "print m , \", \" , n , \", \" , max_(m,n) \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "44 , 22 , 44\n",
- "55 , 22 , 55\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "v = []\n",
- "for k in range(1,5):\n",
- " v.append(1.0/k)\n",
- "\n",
- "for i in range(4):\n",
- " print \"v[\" , i , \"] = \" , v[i]\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "v[ 0 ] = 1.0\n",
- "v[ 1 ] = 0.5\n",
- "v[ 2 ] = 0.333333333333\n",
- "v[ 3 ] = 0.25\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "import sys\n",
- "a = [22, 33, 44]\n",
- "\n",
- "print \"a = \" , hex(id(a))\n",
- "print \"sizeof(int) = \" , sys.getsizeof(1) \n",
- "s = 0\n",
- "for i in a:\n",
- " s += i\n",
- " print \"\\t i = \" , hex(id(i)),\n",
- " print \"\\t *i = \" , i,\n",
- " print \"\\t sum = \" , s\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "a = 0x9bf688c\n",
- "sizeof(int) = 12\n",
- "\t i = 0x8fc0ff4 \t *i = 22 \t sum = 22\n",
- "\t i = 0x8fc0f70 \t *i = 33 \t sum = 55\n",
- "\t i = 0x8fc0eec \t *i = 44 \t sum = 99\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "a = [22, 33, 44, 55, 66]\n",
- "print \"a = \" , hex(id(a)) , \", *a = \" , a[0] \n",
- "for p in a:\n",
- " print \"p = \" , hex(id(p)) , \", *p = \" , p \n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "a = 0x9c6526c , *a = 22\n",
- "p = 0x8fc0ff4 , *p = 22\n",
- "p = 0x8fc0f70 , *p = 33\n",
- "p = 0x8fc0eec , *p = 44\n",
- "p = 0x8fc0e68 , *p = 55\n",
- "p = 0x8fc0de4 , *p = 66\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "def loc(a1,a2,n1,n2):\n",
- " p = []\n",
- " for element in a2:\n",
- " if element in a1:\n",
- " p.append(element)\n",
- " return p\n",
- "\n",
- "a1 = [11, 11, 11, 11, 11, 22, 33, 44, 55]\n",
- "a2 = [11, 11, 11, 22, 33]\n",
- "print \"Array a1 begins at location\\t\" , hex(id(a1 ))\n",
- "print \"Array a2 begins at location\\t\" , hex(id(a2)) \n",
- "p = loc(a1, a2, 9, 5)\n",
- "if (p):\n",
- " print \"Array a2 found at location\\t\" , hex(id(p))\n",
- " for i in range(len(p)):\n",
- " print \"\\t\" , hex(id(p[i])) , \": \" , p[i], \"\\t\" , hex(id(a2[i])) , \": \" , a2[i] \n",
- "else:\n",
- " print \"Not found.\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Array a1 begins at location\t0x9bea56c\n",
- "Array a2 begins at location\t0x9bea62c\n",
- "Array a2 found at location\t0x9bea6cc\n",
- "\t0x8fc1078 : 11 \t0x8fc1078 : 11\n",
- "\t0x8fc1078 : 11 \t0x8fc1078 : 11\n",
- "\t0x8fc1078 : 11 \t0x8fc1078 : 11\n",
- "\t0x8fc0ff4 : 22 \t0x8fc0ff4 : 22\n",
- "\t0x8fc0f70 : 33 \t0x8fc0f70 : 33\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "def get(a):\n",
- " print \"Enter number of items: \"\n",
- " n = int(raw_input())\n",
- " print \"Enter \" , n , \" items, one per line:\"\n",
- " for i in range(n):\n",
- " print \"\\t\" , i+1 , \": \",\n",
- " a.append(float(raw_input()))\n",
- "\n",
- "def print_(a):\n",
- " for i in range(len(a)):\n",
- " print a[i] ,\n",
- " print ''\n",
- "\n",
- "a = []\n",
- "get(a)\n",
- "print_(a)\n",
- "a = []\n",
- "get(a)\n",
- "print_(a)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter number of items: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "4\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter 4 items, one per line:\n",
- "\t1 : "
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "44.4\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " \t2 : "
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "77.7\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " \t3 : "
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "22.2\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " \t4 : "
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "88.8\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 44.4 77.7 22.2 88.8 \n",
- "Enter number of items: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "2\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter 2 items, one per line:\n",
- "\t1 : "
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "3.33\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " \t2 : "
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "9.99\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " 3.33 9.99 \n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "def sort(p, n):\n",
- " for i in range(1,n):\n",
- " for j in range(n-i):\n",
- " if (p[j] > p[j+1]):\n",
- " p[j],p[j+1] = p[j+1],p[j]\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 14
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "def sum_(k,n):\n",
- " # returns the sum f(0) + f(1) + f(2) + . . . + f(n-1):\n",
- " s = 0\n",
- " for i in range(1,n+1):\n",
- " s += k(i)\n",
- " return s\n",
- "\n",
- "def square(k):\n",
- " return k*k\n",
- "\n",
- "def cube(k):\n",
- " return k*k*k\n",
- "\n",
- "\n",
- "print sum_(square,4) # 1 + 4 + 9 + 16\n",
- "print sum_(cube,4) # 1 + 8 + 27 + 64\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "30\n",
- "100\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch8.ipynb b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch8.ipynb
deleted file mode 100644
index a4d4d774..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch8.ipynb
+++ /dev/null
@@ -1,947 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:79346296b970ba1771cf99da135ed51f1d98b24ac99e0b8758fa3cab63c95d45"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "n= [44] # n holds the int 44\n",
- "print \"int n=44; // n holds the int 44:\\n\";\n",
- "print \"\\t\\t n = \" , n \n",
- "print \"\\t\\t &n = \" , hex(id(n))\n",
- "pn = n \n",
- "print \"int* pn=&n; // pn holds the address of n:\\n\";\n",
- "print \"\\t\\t n = \" , n \n",
- "print \"\\t\\t &n = \" , hex(id(n))\n",
- "print \"\\t\\t pn = \" , hex(id(pn)) \n",
- "print \"\\t\\t &pn = \" , hex(id(hex(id(pn))))\n",
- "print \"\\t\\t *pn = \" , pn\n",
- "\n",
- "pn[0] = 77 # changes the value of n to 77\n",
- "print \"*pn = 77; // changes the value of n to 77:\\n\";\n",
- "print \"\\t\\t n = \" , n \n",
- "print \"\\t\\t &n = \" , hex(id(n))\n",
- "print \"\\t\\t pn = \" , hex(id(pn)) \n",
- "print \"\\t\\t &pn = \" , hex(id(hex(id(pn))))\n",
- "print \"\\t\\t *pn = \" , pn\n",
- "\n",
- "q = n \n",
- "print \"int* q=&n; // q also holds the address of n:\\n\";\n",
- "print \"\\t\\t n = \" , n \n",
- "print \"\\t\\t &n = \" , hex(id(n))\n",
- "print \"\\t\\t pn = \" , hex(id(pn)) \n",
- "print \"\\t\\t &pn = \" , hex(id(hex(id(pn))))\n",
- "print \"\\t\\t *pn = \" , pn\n",
- "print \"\\t\\t q = \" , hex(id(q))\n",
- "print \"\\t\\t &q = \" , hex(id(hex(id(hex(id(pn))))))\n",
- "print \"\\t\\t *q = \" , q \n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "int n=44; // n holds the int 44:\n",
- "\n",
- "\t\t n = [44]\n",
- "\t\t &n = 0x9bfb92c\n",
- "int* pn=&n; // pn holds the address of n:\n",
- "\n",
- "\t\t n = [44]\n",
- "\t\t &n = 0x9bfb92c\n",
- "\t\t pn = 0x9bfb92c\n",
- "\t\t &pn = 0x9bf5aa0\n",
- "\t\t *pn = [44]\n",
- "*pn = 77; // changes the value of n to 77:\n",
- "\n",
- "\t\t n = [77]\n",
- "\t\t &n = 0x9bfb92c\n",
- "\t\t pn = 0x9bfb92c\n",
- "\t\t &pn = 0x9c6a760\n",
- "\t\t *pn = [77]\n",
- "int* q=&n; // q also holds the address of n:\n",
- "\n",
- "\t\t n = [77]\n",
- "\t\t &n = 0x9bfb92c\n",
- "\t\t pn = 0x9bfb92c\n",
- "\t\t &pn = 0x9bf5c80\n",
- "\t\t *pn = [77]\n",
- "\t\t q = 0x9bfb92c\n",
- "\t\t &q = 0x9c6a760\n",
- "\t\t *q = [77]\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "s = \"ABCD\"\n",
- "for i in range(4):\n",
- " print \"s[\" , i , \"] = '\" , s[i] , \"'\\n\";\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "s[ 0 ] = ' A '\n",
- "\n",
- "s[ 1 ] = ' B '\n",
- "\n",
- "s[ 2 ] = ' C '\n",
- "\n",
- "s[ 3 ] = ' D '\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "while True:\n",
- " word = raw_input()\n",
- " if len(word) < 2:\n",
- " break\n",
- " l = word.split(' ')\n",
- " for i in l:\n",
- " print '\\t\"' , i , '\"'\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Today's date is March 12, 2000.\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\t\" Today's \"\n",
- "\t\" date \"\n",
- "\t\" is \"\n",
- "\t\" March \"\n",
- "\t\" 12, \"\n",
- "\t\" 2000. \"\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Tomorrow is Monday.\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\t\" Tomorrow \"\n",
- "\t\" is \"\n",
- "\t\" Monday. \"\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "while True:\n",
- " line = raw_input()\n",
- " if len(line) < 2:\n",
- " break\n",
- " print \"\\t[\" , line , \"]\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Once upon a midnight dreary, while I pondered, weak and weary,\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\t[ Once upon a midnight dreary, while I pondered, weak and weary, ]\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Over a many quaint and curious volume of forgotten lore,\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\t[ Over a many quaint and curious volume of forgotten lore, ]\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "\n",
- "while True:\n",
- " word = raw_input()\n",
- " if len(word) < 2:\n",
- " break\n",
- " l = word.split(',')\n",
- " for i in range(len(l)-1):\n",
- " print '\\t[' , l[i] , ']'\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Once upon a midnight dreary, while I pondered, weak and weary,\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\t[ Once upon a midnight dreary ]\n",
- "\t[ while I pondered ]\n",
- "\t[ weak and weary ]\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Over a many quaint and curious volume of forgotten lore,\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\t[ Over a many quaint and curious volume of forgotten lore ]\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "count = 0\n",
- "while True:\n",
- " a = raw_input()\n",
- " if len(a) < 1:\n",
- " break\n",
- " for ch in a:\n",
- " if (ch == 'e'): count+=1\n",
- " \n",
- "print count , \" e's were counted.\\n\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Once upon a midnight dreary, while I pondered, weak and weary,\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Over many a quaint and curious volume of forgotten lore,\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "11 e's were counted.\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "while True:\n",
- " a = raw_input()\n",
- " if len(a) < 1:\n",
- " break\n",
- " print a.title()\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Fourscore and seven years ago our fathers\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Fourscore And Seven Years Ago Our Fathers\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "brought forth upon this continent a new nation,\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Brought Forth Upon This Continent A New Nation,\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "a = raw_input()\n",
- "l = a.split(' ')\n",
- "nos = []\n",
- "for i in l:\n",
- " try:\n",
- " i = int(i)\n",
- " nos.append(i)\n",
- " except:\n",
- " continue\n",
- "m = nos[0]\n",
- "n = nos[1] \n",
- "print m , \" + \" , n , \" = \" , m+n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "what is 305 plus 9416 ?\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "305 + 9416 = 9721\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "name = []\n",
- "count=0\n",
- "\n",
- "print \"Enter at most 4 names with at most 19 characters:\\n\";\n",
- "while (True):\n",
- " n = raw_input()\n",
- " if len(n) < 1:\n",
- " break\n",
- " name.append(n)\n",
- " count += 1\n",
- " \n",
- "print \"The names are:\\n\"\n",
- "for i in range(count):\n",
- " print \"\\t\" , i , \". [\" , name[i] , \"]\" \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter at most 4 names with at most 19 characters:\n",
- "\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "George Washington\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "John Adams\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Thomas Jefferson\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The names are:\n",
- "\n",
- "\t0 . [ George Washington ]\n",
- "\t1 . [ John Adams ]\n",
- "\t2 . [ Thomas Jefferson ]\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "name = []\n",
- "count=0\n",
- "\n",
- "print \"Enter at most 4 names with at most 19 characters:\\n\";\n",
- "while (True):\n",
- " n = raw_input()\n",
- " if len(n) < 1:\n",
- " break\n",
- " name.append(n)\n",
- " count += 1\n",
- " \n",
- "print \"The names are:\\n\"\n",
- "for i in range(count):\n",
- " print \"\\t\" , i , \". [\" , name[i] , \"]\" "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter at most 4 names with at most 19 characters:\n",
- "\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "George Washington\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "John Adams\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Thomas Jefferson\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The names are:\n",
- "\n",
- "\t0 . [ George Washington ]\n",
- "\t1 . [ John Adams ]\n",
- "\t2 . [ Thomas Jefferson ]\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "name = [ \"George Washington\", \"John Adams\", \"Thomas Jefferson\"]\n",
- "print \"The names are:\\n\"\n",
- "for i in range(3):\n",
- " print \"\\t\" , i , \". [\" , name[i] , \"]\"\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The names are:\n",
- "\n",
- "\t0 . [ George Washington ]\n",
- "\t1 . [ John Adams ]\n",
- "\t2 . [ Thomas Jefferson ]\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "s = \"ABCDEFG\"\n",
- "print \"len(\" , s , \") = \" , len(s) \n",
- "print \"len(\\\"\\\") = \" , len(\"\")\n",
- "print \"Enter string: \"\n",
- "b = raw_input()\n",
- "print \"len(\" , b , \") = \" , len(b)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "len( ABCDEFG ) = 7\n",
- "len(\"\") = 0\n",
- "Enter string: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "hello how are you !!!\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "len( hello how are you !!! ) = 21\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "s = \"The Mississippi is a long river.\"\n",
- "print 's = \"' , s , '\"'\n",
- "p = s.find(' ')\n",
- "print \"find(s, ' ') points to s[\" , p , \"].\"\n",
- "p = s.find('s')\n",
- "print \"find(s, 's') points to s[\" , p , \"].\"\n",
- "p = s.rfind('s')\n",
- "print \"reverse find(s, 's') points to s[\" , p , \"].\"\n",
- "p = s.find(\"is\")\n",
- "print \"strstr(s, \\\"is\\\") points to s[\" , p , \"].\"\n",
- "p = s.find(\"isi\")\n",
- "if p== -1:\n",
- " print 's.find(\"isi\") returns NULL'\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "s = \" The Mississippi is a long river. \"\n",
- "find(s, ' ') points to s[ 3 ].\n",
- "find(s, 's') points to s[ 6 ].\n",
- "reverse find(s, 's') points to s[ 17 ].\n",
- "strstr(s, \"is\") points to s[ 5 ].\n",
- "s.find(\"isi\") returns NULL\n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "s1 = \"ABCDEFG\"\n",
- "s2 = \"XYZ\" \n",
- "print \"Before strcpy(s1,s2):\\n\" \n",
- "print \"\\ts1 = [\" , s1 , \"], length = \" , len(s1) \n",
- "print \"\\ts2 = [\" , s2 , \"], length = \" , len(s2) \n",
- "s1 = s2\n",
- "print \"After strcpy(s1,s2):\\n\" \n",
- "print \"\\ts1 = [\" , s1 , \"], length = \" , len(s1) \n",
- "print \"\\ts2 = [\" , s2 , \"], length = \" , len(s2) \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Before strcpy(s1,s2):\n",
- "\n",
- "\ts1 = [ ABCDEFG ], length = 7\n",
- "\ts2 = [ XYZ ], length = 3\n",
- "After strcpy(s1,s2):\n",
- "\n",
- "\ts1 = [ XYZ ], length = 3\n",
- "\ts2 = [ XYZ ], length = 3\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "s1 = \"ABCDEFG\"\n",
- "s2 = \"XYZ\" \n",
- "print \"Before strcpy(s1,s2,2):\\n\" \n",
- "print \"\\ts1 = [\" , s1 , \"], length = \" , len(s1) \n",
- "print \"\\ts2 = [\" , s2 , \"], length = \" , len(s2) \n",
- "s1 = s2[:2] + s1[2:]\n",
- "print \"After strcpy(s1,s2,2):\\n\" \n",
- "print \"\\ts1 = [\" , s1 , \"], length = \" , len(s1) \n",
- "print \"\\ts2 = [\" , s2 , \"], length = \" , len(s2) \n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Before strcpy(s1,s2,2):\n",
- "\n",
- "\ts1 = [ ABCDEFG ], length = 7\n",
- "\ts2 = [ XYZ ], length = 3\n",
- "After strcpy(s1,s2,2):\n",
- "\n",
- "\ts1 = [ XYCDEFG ], length = 7\n",
- "\ts2 = [ XYZ ], length = 3\n"
- ]
- }
- ],
- "prompt_number": 18
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "s1 = \"ABCDEFG\"\n",
- "s2 = \"XYZ\" \n",
- "print \"Before string concatination :\\n\" \n",
- "print \"\\ts1 = [\" , s1 , \"], length = \" , len(s1) \n",
- "print \"\\ts2 = [\" , s2 , \"], length = \" , len(s2) \n",
- "s1 += s2\n",
- "print \"After string concatination :\" \n",
- "print \"\\ts1 = [\" , s1 , \"], length = \" , len(s1) \n",
- "print \"\\ts2 = [\" , s2 , \"], length = \" , len(s2) "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Before string concatination :\n",
- "\n",
- "\ts1 = [ ABCDEFG ], length = 7\n",
- "\ts2 = [ XYZ ], length = 3\n",
- "After string concatination :\n",
- "\ts1 = [ ABCDEFGXYZ ], length = 10\n",
- "\ts2 = [ XYZ ], length = 3\n"
- ]
- }
- ],
- "prompt_number": 19
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "s1 = \"ABCDEFG\"\n",
- "s2 = \"XYZ\" \n",
- "print \"Before string concatination :\\n\" \n",
- "print \"\\ts1 = [\" , s1 , \"], length = \" , len(s1) \n",
- "print \"\\ts2 = [\" , s2 , \"], length = \" , len(s2) \n",
- "s1 += s2[:2]\n",
- "print \"After string concatination :\" \n",
- "print \"\\ts1 = [\" , s1 , \"], length = \" , len(s1) \n",
- "print \"\\ts2 = [\" , s2 , \"], length = \" , len(s2) "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Before string concatination :\n",
- "\n",
- "\ts1 = [ ABCDEFG ], length = 7\n",
- "\ts2 = [ XYZ ], length = 3\n",
- "After string concatination :\n",
- "\ts1 = [ ABCDEFGXY ], length = 9\n",
- "\ts2 = [ XYZ ], length = 3\n"
- ]
- }
- ],
- "prompt_number": 20
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "s = \"Today's date is March 12, 2000.\"\n",
- "\n",
- "print \"The string is: [\" , s , \"] \\nIts tokens are: \"\n",
- "p = s.split(\" \")\n",
- "\n",
- "for i in p:\n",
- " print \"\\t[\" , i , \"] \"\n",
- "\n",
- "print \"Now the string is: [\" , p[0] , \"] \";\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The string is: [ Today's date is March 12, 2000. ] \n",
- "Its tokens are: \n",
- "\t[ Today's ] \n",
- "\t[ date ] \n",
- "\t[ is ] \n",
- "\t[ March ] \n",
- "\t[ 12, ] \n",
- "\t[ 2000. ] \n",
- "Now the string is: [ Today's ] \n"
- ]
- }
- ],
- "prompt_number": 21
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "def strpbrk(s,s1):\n",
- " found = []\n",
- " for i in range(len(s1)):\n",
- " if s1[i] in s:\n",
- " index = s.find(s1[i])\n",
- " found.append(index)\n",
- " if found:\n",
- " return min(found)\n",
- " return None\n",
- " \n",
- "\n",
- "s = \"The Mississippi is a long river.\"\n",
- "print 's = \"' , s , '\"'\n",
- "p = strpbrk(s, \"nopqr\")\n",
- "print 'strpbrk(s, \"nopqr\") points to s[' , p , \"].\"\n",
- "p = strpbrk(s, \"NOPQR\")\n",
- "if (p == None):\n",
- " print 'strpbrk(s, \"NOPQR\") returns NULL.\\n'"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "s = \" The Mississippi is a long river. \"\n",
- "strpbrk(s, \"nopqr\") points to s[ 12 ].\n",
- "strpbrk(s, \"NOPQR\") returns NULL.\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 22
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch9.ipynb b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch9.ipynb
deleted file mode 100644
index d38faaa6..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch9.ipynb
+++ /dev/null
@@ -1,394 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:636fa14bc9bbc0edbdee2b8486af1239be5ff3d58b955831baa9b4ccd512a82c"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "while True:\n",
- " try:\n",
- " n = int(raw_input())\n",
- " print \"n = \" , n \n",
- " except:\n",
- " break"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "46\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "n = 46\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "22\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "n = 22\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "44\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "n = 44\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "66\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "n = 66\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "88\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "n = 88\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "33,\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "king = [] # defines king to be an array \n",
- "n=0\n",
- "while True:\n",
- " name = raw_input()\n",
- " if len(name) < 1:\n",
- " break\n",
- " king.append(name)\n",
- " n += 1\n",
- "# now n == the number of names read\n",
- "for i in range(n):\n",
- " print '\\t' , i+1 , \". \" , king[i] "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Kenneth II (971-995)\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Constantine III (995-997)\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Kenneth III (997-1005)\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Malcolm II (1005-1034)\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Duncan I (1034-1040)\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Macbeth (1040-1057)\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Lulach (1057-1058)\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Malcolm III (1058-1093)\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\t1 . Kenneth II (971-995)\n",
- "\t2 . Constantine III (995-997)\n",
- "\t3 . Kenneth III (997-1005)\n",
- "\t4 . Malcolm II (1005-1034)\n",
- "\t5 . Duncan I (1034-1040)\n",
- "\t6 . Macbeth (1040-1057)\n",
- "\t7 . Lulach (1057-1058)\n",
- "\t8 . Malcolm III (1058-1093)\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "infile = open(\"input.txt\",\"r\")\n",
- "outfile = open(\"output.txt\",\"w\")\n",
- "\n",
- "for i in infile:\n",
- " s = i.title()\n",
- " outfile.write(s)\n",
- "\n",
- "infile.close()\n",
- "outfile.close()"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "ename": "IOError",
- "evalue": "[Errno 2] No such file or directory: 'input.txt'",
- "output_type": "pyerr",
- "traceback": [
- "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mIOError\u001b[0m Traceback (most recent call last)",
- "\u001b[1;32m<ipython-input-3-60ee428ecf4c>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 5\u001b[0m '''\n\u001b[0;32m 6\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 7\u001b[1;33m \u001b[0minfile\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"input.txt\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m\"r\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 8\u001b[0m \u001b[0moutfile\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"output.txt\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m\"w\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 9\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
- "\u001b[1;31mIOError\u001b[0m: [Errno 2] No such file or directory: 'input.txt'"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "fin1 = open(\"north.dat\",\"r\")\n",
- "fin2 = open(\"south.dat\",\"r\")\n",
- "fout = open(\"combined.dat\",\"w\")\n",
- "\n",
- "file1 = []\n",
- "file2 = []\n",
- "for i in fin1:\n",
- " try:\n",
- " s = i.split(\" \")\n",
- " for j in s:\n",
- " file1.append(int(j))\n",
- " except:\n",
- " continue\n",
- " \n",
- "for i in fin2:\n",
- " try:\n",
- " s = i.split(\" \")\n",
- " for j in s:\n",
- " file2.append(int(j))\n",
- " except:\n",
- " continue\n",
- "\n",
- "\n",
- "for i in sorted(file1 + file2):\n",
- " fout.write(str(i) + \" \")\n",
- "\n",
- "fin1.close()\n",
- "fin2.close()\n",
- "fout.close()"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "ename": "IOError",
- "evalue": "[Errno 2] No such file or directory: 'north.dat'",
- "output_type": "pyerr",
- "traceback": [
- "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mIOError\u001b[0m Traceback (most recent call last)",
- "\u001b[1;32m<ipython-input-4-e14718f30215>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 3\u001b[0m '''\n\u001b[0;32m 4\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 5\u001b[1;33m \u001b[0mfin1\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"north.dat\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m\"r\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 6\u001b[0m \u001b[0mfin2\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"south.dat\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m\"r\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[0mfout\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"combined.dat\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m\"w\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
- "\u001b[1;31mIOError\u001b[0m: [Errno 2] No such file or directory: 'north.dat'"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "def print_(oss):\n",
- " print 'oss.str() = \"' , str(oss) , '\"'\n",
- "\n",
- "s=\"ABCDEFG\"\n",
- "n=33\n",
- "x=2.718\n",
- "l = ''\n",
- "print_(l)\n",
- "l += s\n",
- "print_(l)\n",
- "l += ( \" \" + str(n) )\n",
- "print_(l)\n",
- "l += ( \" \" + str(x) )\n",
- "print_(l)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "oss.str() = \" \"\n",
- "oss.str() = \" ABCDEFG \"\n",
- "oss.str() = \" ABCDEFG 33 \"\n",
- "oss.str() = \" ABCDEFG 33 2.718 \"\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "def print_(iss,s='',n=0,x=0.0):\n",
- " print 's = \"' , s , '\", n = ' , n , \", x = \" , x, ', iss.str() = \"' \\\n",
- " , iss , '\"' \n",
- "\n",
- "s=\"\"\n",
- "n=0\n",
- "x=0.0\n",
- "l = ''\n",
- "iss = \"ABCDEFG 44 3.14\"\n",
- "print_(iss)\n",
- "s = \"ABCDEFG\"\n",
- "print_(iss,s)\n",
- "n = 44\n",
- "print_(iss,s,n)\n",
- "x = 3.14\n",
- "print_(iss,s,n,x)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "s = \" \", n = 0 , x = 0.0 , iss.str() = \" ABCDEFG 44 3.14 \"\n",
- "s = \" ABCDEFG \", n = 0 , x = 0.0 , iss.str() = \" ABCDEFG 44 3.14 \"\n",
- "s = \" ABCDEFG \", n = 44 , x = 0.0 , iss.str() = \" ABCDEFG 44 3.14 \"\n",
- "s = \" ABCDEFG \", n = 44 , x = 3.14 , iss.str() = \" ABCDEFG 44 3.14 \"\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashu1.png b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashu1.png
deleted file mode 100644
index 13e13f29..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashu1.png
+++ /dev/null
Binary files differ
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashu2.png b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashu2.png
deleted file mode 100644
index e1bc353c..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashu2.png
+++ /dev/null
Binary files differ
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashu3.png b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashu3.png
deleted file mode 100644
index 60dd1e4b..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashu3.png
+++ /dev/null
Binary files differ
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashutosh-3-1_1.png b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashutosh-3-1_1.png
deleted file mode 100644
index 13e13f29..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashutosh-3-1_1.png
+++ /dev/null
Binary files differ
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashutosh-3-2_1.png b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashutosh-3-2_1.png
deleted file mode 100644
index e1bc353c..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashutosh-3-2_1.png
+++ /dev/null
Binary files differ
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashutosh-3-3_1.png b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashutosh-3-3_1.png
deleted file mode 100644
index 60dd1e4b..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/screenshots/ashutosh-3-3_1.png
+++ /dev/null
Binary files differ