summaryrefslogtreecommitdiff
path: root/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch11.ipynb
diff options
context:
space:
mode:
authorroot2014-07-07 16:45:58 +0530
committerroot2014-07-07 16:45:58 +0530
commit1b0d935754549d175d2bad3d5eb5dc541bd7a0d4 (patch)
treefe73fe578ee4ce75d83ca61cdc533c4110d03a2a /Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch11.ipynb
parentfffcc90da91b66ee607066d410b57f34024bd1de (diff)
downloadPython-Textbook-Companions-1b0d935754549d175d2bad3d5eb5dc541bd7a0d4.tar.gz
Python-Textbook-Companions-1b0d935754549d175d2bad3d5eb5dc541bd7a0d4.tar.bz2
Python-Textbook-Companions-1b0d935754549d175d2bad3d5eb5dc541bd7a0d4.zip
removing unwanted files
Diffstat (limited to 'Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch11.ipynb')
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch11.ipynb686
1 files changed, 0 insertions, 686 deletions
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