diff options
54 files changed, 10487 insertions, 0 deletions
diff --git a/Beginning_C++_through_game_programming/README.txt b/Beginning_C++_through_game_programming/README.txt new file mode 100755 index 00000000..1d5d0c17 --- /dev/null +++ b/Beginning_C++_through_game_programming/README.txt @@ -0,0 +1,10 @@ +Contributed By: Jatin Pavagadhi +Course: mca +College/Institute/Organization: C-DEC , Pune +Department/Designation: Developer +Book Title: Beginning C++ through game programming +Author: Michael Dawson +Publisher: Course Tech., USA +Year of publication: 2011 +Isbn: 9781435457423 +Edition: 3
\ No newline at end of file diff --git a/Beginning_C++_through_game_programming/ch1.ipynb b/Beginning_C++_through_game_programming/ch1.ipynb new file mode 100755 index 00000000..2b946f8b --- /dev/null +++ b/Beginning_C++_through_game_programming/ch1.ipynb @@ -0,0 +1,427 @@ +{ + "metadata": { + "name": "ch1" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1 : Types, Variables, and Standard I/O: Lost Fortune" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Exmaple 1.1 Page no : 6" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "prints Game Over\n", + "'''\n", + "\n", + "print \"Game Over!\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Game Over!\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Exmaple 1.2 Page no : 11" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "prints \"Game Over!\"\n", + "'''\n", + "\n", + "print \"Game Over!\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Game Over!\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Exmaple 1.3 Page no : 12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "print \"Game Over!\"\n", + "'''\n", + "\n", + "print \"Game Over!\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Game Over!\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Exmaple 1.4 Page no : 13" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "Expensive calculator\n", + "'''\n", + "\n", + "print \"7 + 3 = \" , 7 + 3\n", + "print \"7 - 3 = \" , 7 - 3\n", + "print \"7 * 3 = \" , 7 * 3 \n", + "print \"7 / 3 = \" , 7 / 3 \n", + "print \"7.0 / 3.0 = \" , 7.0 / 3.0 \n", + "print \"7 % 3 = \" , 7 % 3 \n", + "print \"7 + 3 * 5 = \" , 7 + 3 * 5\n", + "print \"(7 + 3) * 5 = \" , (7 + 3) * 5" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "7 + 3 = 10\n", + "7 - 3 = 4\n", + "7 * 3 = 21\n", + "7 / 3 = 2\n", + "7.0 / 3.0 = 2.33333333333\n", + "7 % 3 = 1\n", + "7 + 3 * 5 = 22\n", + "(7 + 3) * 5 = 50\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.5 Page no : 17" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "Game Stats\n", + "Demonstrates declaring and initializing variables\n", + "'''\n", + "score = 0;\n", + "distance = 1200.76;\n", + "playAgain = 'y'\n", + "shieldsUp = True;\n", + "lives = 3;\n", + "aliensKilled = 10;\n", + "engineTemp = 6572.89;\n", + "print \"\\nscore: \" , score \n", + "print \"distance: \" , distance\n", + "print \"playAgain: \" , playAgain\n", + "#skipping shieldsUp since you dont generally print Boolean values\n", + "print \"lives: \" , lives\n", + "print \"aliensKilled: \" , aliensKilled\n", + "print \"engineTemp: \" , engineTemp\n", + "\n", + "print \"\\nHow much fuel? \",\n", + "fuel = 5 # raw_input()\n", + "\n", + "print \"fuel: \" , fuel\n", + "bonus = 10;\n", + "print \"\\nbonus: \" , bonus" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "score: 0\n", + "distance: 1200.76\n", + "playAgain: y\n", + "lives: 3\n", + "aliensKilled: 10\n", + "engineTemp: 6572.89\n", + "\n", + "How much fuel? fuel: 5\n", + "\n", + "bonus: 10\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.6 Page no : 35" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "small calculation\n", + "'''\n", + "\n", + "score = 5000;\n", + "print \"score: \" , score\n", + "#altering the value of a variable\n", + "score = score + 100;\n", + "print \"score: \" , score\n", + "#combined assignment operator\n", + "score += 100;\n", + "print \"score: \" , score\n", + "# increment operators\n", + "lives = 3;\n", + "lives += 1\n", + "print \"lives: \", lives\n", + "\n", + "lives = 3;\n", + "lives += 1\n", + "print \"lives: \", lives\n", + "\n", + "lives = 3;\n", + "lives += 1\n", + "bonus = lives * 10;\n", + "print \"lives, bonus = \" , lives , \", \" , bonus \n", + "\n", + "lives = 3;\n", + "bonus = lives * 10;\n", + "lives += 1\n", + "print \"lives, bonus = \" , lives , \", \" , bonus \n", + "#integer wrap around\n", + "score = 4294967295;\n", + "print \"\\nscore: \" , score\n", + "score += 1\n", + "print \"score: \", score " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "score: 5000\n", + "score: 5100\n", + "score: 5200\n", + "lives: 4\n", + "lives: 4\n", + "lives, bonus = 4 , 40\n", + "lives, bonus = 4 , 30\n", + "\n", + "score: 4294967295\n", + "score: 4294967296\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.7 Page no : 30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "Game Stats 3.0\n", + "Demonstrates constants\n", + "'''\n", + "ALIEN_POINTS = 150;\n", + "aliensKilled = 10;\n", + "score = aliensKilled * ALIEN_POINTS;\n", + "print \"score: \" , score\n", + "NOVICE = 0\n", + "EASY = 1\n", + "NORMAL =2\n", + "HARD=3\n", + "UNBEATABLE=4\n", + "myDifficulty = EASY;\n", + "FIGHTER_COST = 25\n", + "BOMBER_COST=26\n", + "CRUISER_COST = 50\n", + "myShipCost = BOMBER_COST;\n", + "print \"\\nTo upgrade my ship to a Cruiser will cost\" , (CRUISER_COST - myShipCost) , \" Resource Points.\\n\";" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "score: 1500\n", + "\n", + "To upgrade my ship to a Cruiser will cost 24 Resource Points.\n", + "\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.8 Page no : 33" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "// Lost Fortune\n", + "// A personalized adventure\n", + "'''\n", + "GOLD_PIECES = 900;\n", + "\n", + "print \"Welcome to Lost Fortune\\n\\n\";\n", + "print \"Please enter the following for your personalized adventure\\n\";\n", + "print \"Enter a number: \";\n", + "adventurers = 10 # int(raw_input())\n", + "print \"Enter a number, smaller than the first: \";\n", + "killed = 5 #int(raw_input())\n", + "\n", + "survivors = adventurers - killed;\n", + "print \"Enter your last name: \";\n", + "leader = 'xyz' #raw_input()\n", + "#tell the story\n", + "print \"\\nA brave group of \" , adventurers , \" set out on a quest \";\n", + "print \"- in search of the lost treasure of the Ancient Dwarves. \";\n", + "print \"The group was led by that legendary rogue, \" , leader , \".\\n\";\n", + "print \"\\nAlong the way, a band of marauding ogres ambushed the party. \";\n", + "print \"All fought bravely under the command of \" , leader,\n", + "print \", and the ogres were defeated, but at a cost. \",\n", + "print \"Of the adventurers, \" , killed , \" were vanquished, \",\n", + "print \"leaving just \" , survivors , \" in the group.\\n\"\n", + "\n", + "print \"\\nThe party was about to give up all hope. \";\n", + "print \"But while laying the deceased to rest, \";\n", + "print \"they stumbled upon the buried fortune. \";\n", + "print \"So the adventurers split \" , GOLD_PIECES , \" gold pieces.\" ,\n", + "print leader , \" held on to the extra \" , (GOLD_PIECES % survivors),\n", + "print \" pieces to keep things fair of course.\\n\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Welcome to Lost Fortune\n", + "\n", + "\n", + "Please enter the following for your personalized adventure\n", + "\n", + "Enter a number: \n", + "Enter a number, smaller than the first: \n", + "Enter your last name: \n", + "\n", + "A brave group of 10 set out on a quest \n", + "- in search of the lost treasure of the Ancient Dwarves. \n", + "The group was led by that legendary rogue, xyz .\n", + "\n", + "\n", + "Along the way, a band of marauding ogres ambushed the party. \n", + "All fought bravely under the command of xyz , and the ogres were defeated, but at a cost. Of the adventurers, 5 were vanquished, leaving just 5 in the group.\n", + "\n", + "\n", + "The party was about to give up all hope. \n", + "But while laying the deceased to rest, \n", + "they stumbled upon the buried fortune. \n", + "So the adventurers split 900 gold pieces. xyz held on to the extra 0 pieces to keep things fair of course.\n", + "\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Beginning_C++_through_game_programming/ch10.ipynb b/Beginning_C++_through_game_programming/ch10.ipynb new file mode 100755 index 00000000..393c4d1c --- /dev/null +++ b/Beginning_C++_through_game_programming/ch10.ipynb @@ -0,0 +1,670 @@ +{ + "metadata": { + "name": "ch10" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 10 : Inheritance and Polymorphism: Blackjack" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 10.1 page no: 334" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "//Simple Boss\n", + "//Demonstrates inheritance\n", + "'''\n", + "\n", + "class Enemy:\n", + " def __init__(self):\n", + " self.m_Damage = 10\n", + "\n", + " def Attack(self):\n", + " print \"An enemy attacks and inflicts \" , self.m_Damage , \" damage points!\";\n", + " \n", + " def __del__(self):\n", + " print \"In Enemy destructor, deleting m_pDamage.\\n\";\n", + "\n", + "class Boss(Enemy):\n", + " def __init__(self):\n", + " Enemy.__init__(self)\n", + " self.m_DamageMultiplier = 3\n", + "\n", + " def SpecialAttack(self):\n", + " print \"A boss attacks and inflicts \" , (self.m_DamageMultiplier * self.m_Damage),\n", + " print \" damage points!\";\n", + "\n", + "print \"Creating an enemy.\\n\";\n", + "enemy1 = Enemy()\n", + "enemy1.Attack();\n", + "print \"\\nCreating a boss.\\n\";\n", + "boss1 = Boss()\n", + "boss1.Attack();\n", + "boss1.SpecialAttack();" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating an enemy.\n", + "\n", + "An enemy attacks and inflicts 10 damage points!\n", + "\n", + "Creating a boss.\n", + "\n", + "An enemy attacks and inflicts 10 damage points!\n", + "A boss attacks and inflicts 30 damage points!\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 10.2 page no : 338" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "//Simple Boss 2.0\n", + "//Demonstrates access control under inheritance\n", + "'''\n", + "\n", + "\n", + "class Enemy:\n", + " def __init__(self):\n", + " self.m_Damage = 10\n", + "\n", + " def Attack(self):\n", + " print \"Attack inflicts \" , self.m_Damage , \" damage points!\";\n", + "\n", + "class Boss(Enemy):\n", + " def __init__(self):\n", + " Enemy.__init__(self)\n", + " self.m_DamageMultiplier = 3\n", + "\n", + " def SpecialAttack(self):\n", + " print \"Special Attack inflicts \" , (self.m_DamageMultiplier * self.m_Damage),\n", + " print \" damage points!\";\n", + "\n", + "print \"Creating an enemy.\\n\";\n", + "enemy1 = Enemy()\n", + "enemy1.Attack();\n", + "print \"\\nCreating a boss.\\n\";\n", + "boss1 = Boss()\n", + "boss1.Attack();\n", + "boss1.SpecialAttack();" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating an enemy.\n", + "\n", + "Attack inflicts 10 damage points!\n", + "\n", + "Creating a boss.\n", + "\n", + "Attack inflicts 10 damage points!\n", + "Special Attack inflicts 30 damage points!\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 10.3 page no : 343" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "//Overriding Boss\n", + "//Demonstrates calling and overriding base member functions\n", + "'''\n", + "class Enemy:\n", + " def __init__(self,d=10):\n", + " self.m_Damage = d\n", + "\n", + " def Attack(self):\n", + " print \"Attack inflicts \" , self.m_Damage , \" damage points!\";\n", + "\n", + " def Taunt(self):\n", + " print \"The enemy says he will fight you.\";\n", + " __Attack = Attack \n", + "\n", + "\n", + "class Boss(Enemy):\n", + " def __init__(self,d=30):\n", + " Enemy.__init__(self)\n", + " self.m_DamageMultiplier = d\n", + "\n", + " def SpecialAttack(self):\n", + " print \"Special Attack inflicts \" , (self.m_DamageMultiplier * self.m_Damage),\n", + " print \" damage points!\";\n", + "\n", + " def Taunt(self): #override base class member function\n", + " print \"The boss says he will end your pitiful existence.\"\n", + "\n", + " def Attack(self): #override base class member function\n", + " #call base class member function\n", + " Enemy.Attack(self)\n", + " print \" And laughs heartily at you.\\n\";\n", + "\n", + "\n", + "print \"Enemy object :\";\n", + "enemy1 = Enemy()\n", + "enemy1.Taunt()\n", + "enemy1.Attack();\n", + "print \"\\n boss object.\\n\";\n", + "boss1 = Boss()\n", + "boss1.Taunt()\n", + "boss1.Attack();\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enemy object :\n", + "The enemy says he will fight you.\n", + "Attack inflicts 10 damage points!\n", + "\n", + " boss object.\n", + "\n", + "The boss says he will end your pitiful existence.\n", + "Attack inflicts 10 damage points!\n", + " And laughs heartily at you.\n", + "\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 10.4 page no : 341,348" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "//Polymorphic Bad Guy\n", + "//Demonstrates calling member functions dynamically\n", + "'''\n", + "\n", + "class Enemy:\n", + " def __init__(self,d=10):\n", + " self.m_Damage = d\n", + "\n", + " def Attack(self):\n", + " print \"Attack inflicts \" , self.m_Damage , \" damage points!\";\n", + "\n", + " def __del__(self):\n", + " print \"In Enemy destructor, deleting m_pDamage.\";\n", + " \n", + "class Boss(Enemy):\n", + " def __init__(self,d=30):\n", + " Enemy.__init__(self)\n", + " self.m_DamageMultiplier = d\n", + "\n", + " def SpecialAttack(self):\n", + " print \"Special Attack inflicts \" , (self.m_DamageMultiplier * self.m_Damage),\n", + " print \" damage points!\";\n", + "\n", + " def Taunt(self): #override base class member function\n", + " print \"The boss says he will end your pitiful existence.\"\n", + "\n", + " def Attack(self): #override base class member function\n", + " #call base class member function\n", + " Enemy.Attack(self)\n", + " print \" And laughs heartily at you.\\n\";\n", + "\n", + " def __del__(self):\n", + " Enemy.__del__(self)\n", + " print \"In Boss destructor, deleting m_pMultiplier.\";\n", + " self.m_pMultiplier = 0;\n", + "\n", + "print \"Calling Attack() on Boss object through pointer to Enemy:\"\n", + "pBadGuy = Boss();\n", + "pBadGuy.Attack();\n", + "print \"\\nDeleting pointer to Enemy:\\n\";\n", + "pBadGuy = 0;" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Calling Attack() on Boss object through pointer to Enemy:\n", + "Attack inflicts 10 damage points!\n", + " And laughs heartily at you.\n", + "\n", + "\n", + "Deleting pointer to Enemy:\n", + "\n", + "In Enemy destructor, deleting m_pDamage.\n", + "In Boss destructor, deleting m_pMultiplier.\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 10.5 page no : 353" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "//Abstract Creature\n", + "//Demonstrates abstract classes\n", + "'''\n", + "class Creature :\n", + " def __init__(self,h=100):\n", + " self.m_Health = h\n", + " \n", + " def Greet(self): # pure virtual member function\n", + " pass\n", + "\n", + " def DisplayHealth(self):\n", + " print \"Health: \" , self.m_Health\n", + "\n", + "\n", + "class Orc(Creature):\n", + " def __init__(self,h=120):\n", + " Creature.__init__(self,h)\n", + "\n", + " def Greet(self):\n", + " print \"The orc grunts hello.\\n\";\n", + "\n", + "pCreature = Orc();\n", + "pCreature.Greet();\n", + "pCreature.DisplayHealth();" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The orc grunts hello.\n", + "\n", + "Health: 120\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 10.6, page no : 361-379" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "defining game class.\n", + "Note : this would give error as we have not initialized player class here.\n", + "'''\n", + "\n", + "ACE = 1\n", + "TWO = 2\n", + "THREE = 3\n", + "FOUR = 4\n", + "FIVE = 5\n", + "SIX = 6\n", + "SEVEN = 7\n", + "EIGHT = 8\n", + "NINE = 9\n", + "TEN = 10\n", + "JACK = 11\n", + "QUEEN = 12\n", + "KING = 13\n", + "\n", + "CLUBS = 0\n", + "DIAMONDS = 1\n", + "HEARTS = 2\n", + "SPADES = 3\n", + "\n", + " \n", + "class Card:\n", + " def __init__(self,r = ACE,s = SPADES,ifu = True): #returns the value of a card, 1 - 11\n", + " self.m_Rank = r\n", + " self.m_Suit = s\n", + " self.m_IsFaceUp =ifu\n", + "\n", + " def GetValue(self):\n", + " #if a cards is face down, its value is 0\n", + " value = 0;\n", + " if (m_IsFaceUp):\n", + " #value is number showing on card\n", + " value = m_Rank;\n", + " #value is 10 for face cards\n", + " if (value > 10):\n", + " value = 10;\n", + " return value;\n", + "\n", + " def Flip(self):\n", + " self.m_IsFaceUp = not (m_IsFaceUp);\n", + "\n", + "class Hand:\n", + " def __init__(self):\n", + " self.m_Cards = []\n", + "\n", + " def __del__(self):\n", + " self.Clear() \n", + "\n", + " def Add(self,pCard):\n", + " self.m_Cards.append(pCard);\n", + "\n", + " def Clear(self):\n", + " #iterate through vector, freeing all memory on the heap\n", + " self.m_Cards = []\n", + "\n", + " def GetTotal(self):\n", + " #if no cards in hand, return 0\n", + " if (self.m_Cards.empty()):\n", + " return 0;\n", + " #if a first card has value of 0, then card is face down; return 0\n", + " if (m_Cards[0].GetValue() == 0):\n", + " return 0;\n", + " #add up card values, treat each ace as 1\n", + " total = 0;\n", + " for i in self.m_Cards:\n", + " total += i.GetValue()\n", + " #determine if hand contains an ace\n", + " containsAce = False;\n", + " for i in self.m_Cards:\n", + " if i.GetValue() == Card.ACE:\n", + " containsAce = True;\n", + "\n", + " #if hand contains ace and total is low enough, treat ace as 11\n", + " if (containsAce and total <= 11):\n", + " #add only 10 since we've already added 1 for the ace\n", + " total += 10;\n", + " return total;\n", + "\n", + "\n", + "class GenericPlayer(Hand):\n", + " def __init__(self,name):\n", + " self.m_Name = name\n", + "\n", + " def __del__(self):\n", + " pass\n", + "\n", + " def IsBusted(self):\n", + " return (self.GetTotal() > 21);\n", + "\n", + " def Bust(self):\n", + " print self.m_Name , \" busts.\";\n", + "\n", + "class Player(GenericPlayer):\n", + " def _init_(self,name):\n", + " GenericPlayer.__init__(self,name)\n", + " \n", + " def _del_(self):\n", + " pass\n", + "\n", + " def IsHitting(self):\n", + " print self.m_Name , \", do you want a hit? (Y/N): \",\n", + " response = raw_input()\n", + " return (response == 'y' or response == 'Y');\n", + "\n", + " def Win(self):\n", + " print self.m_Name , \" wins.\";\n", + "\n", + " def Lose(self):\n", + " print self.m_Name , \" loses.\";\n", + "\n", + " def Push(self):\n", + " print self.m_Name , \" pushes.\";\n", + "\n", + "class House(GenericPlayer):\n", + " def __init__(self,name):\n", + " GenericPlayer.__init__(self,name)\n", + "\n", + " def __del__(self):\n", + " pass\n", + "\n", + " def IsHitting(self):\n", + " return (self.GetTotal() <= 16)\n", + "\n", + " def FlipFirstCard(self):\n", + " if (not self.m_Cards):\n", + " m_Cards[0].Flip();\n", + " else:\n", + " print \"No card to flip!\";\n", + " \n", + "class Deck(Hand):\n", + " def __init__(self):\n", + " self.m_Cards = []\n", + " self.Populate();\n", + " \n", + " def __del__(self):\n", + " pass\n", + " \n", + " def Populate(self):\n", + " self.Clear();\n", + " #create standard deck\n", + " for s in range(Card.CLUBS,Card.SPADES+1):\n", + " for r in range(Card.ACE,Card.KING+1):\n", + " self.Add(Card(r,s))\n", + "\n", + " def Shuffle(self):\n", + " pass\n", + "\n", + " def Deal(self, aHand):\n", + " if (not m_Cards):\n", + " aHand.Add(self.m_Cards[-1]);\n", + " self.m_Cards.pop();\n", + " else:\n", + " print \"Out of cards. Unable to deal.\";\n", + "\n", + " def AdditionalCards(self,aGenericPlayer):\n", + " print ''\n", + " #continue to deal a card as long as generic player isn't busted and\n", + " #wants another hit\n", + " while ( not (aGenericPlayer.IsBusted()) and aGenericPlayer.IsHitting() ):\n", + " self.Deal(aGenericPlayer);\n", + " print aGenericPlayer\n", + " if (aGenericPlayer.IsBusted()):\n", + " aGenericPlayer.Bust();\n", + " \n", + "\n", + "class Game:\n", + " def __init__(self,names):\n", + " #create a vector of players from a vector of names\n", + " self.pName = []\n", + " for i in names:\n", + " self.pName.append(Player(i))\n", + " self.m_Deck.Populate();\n", + " self.m_Deck.Shuffle();\n", + "\n", + " def __del__(self):\n", + " pass\n", + " \n", + " def Play(self):\n", + " # deal initial 2 cards to everyone\n", + " for i in range(2):\n", + " for pPlayer in self.m_Players:\n", + " self.m_Deck.Deal(*pPlayer);\n", + " self.m_Deck.Deal(m_House);\n", + " #hide house's first card\n", + " self.m_House.FlipFirstCard();\n", + " for pPlayer in self.m_Players:\n", + " print pPlayer \n", + "\n", + " print self.m_House\n", + " #deal additional cards to players\n", + " \n", + " for pPlayer in self.m_Players:\n", + " self.m_Deck.AdditionalCards(pPlayer);\n", + "\n", + " #reveal house's first card\n", + " self.m_House.FlipFirstCard();\n", + " print self.m_House;\n", + " #deal additional cards to house\n", + " self.m_Deck.AdditionalCards(m_House);\n", + " if (self.m_House.IsBusted()):\n", + " #everyone still playing wins\n", + " for pPlayer in self.m_Players:\n", + " if ( not (pPlayer.IsBusted()) ):\n", + " pPlayer.Win();\n", + " else:\n", + " #compare each player still playing to house\n", + " for pPlayer in self.m_Players:\n", + " if ( not (pPlayer.IsBusted()) ):\n", + " if (pPlayer.GetTotal() > self.m_House.GetTotal()):\n", + " pPlayer.Win();\n", + " elif (pPlayer.GetTotal() < self.m_House.GetTotal()):\n", + " pPlayer.Lose();\n", + " else:\n", + " pPlayer.Push();\n", + "\n", + " #remove everyones cards\n", + " for pPlayer in self.m_Players:\n", + " pPlayer.Clear();\n", + "\n", + " self.m_House.Clear();\n", + "\n", + "print \"\\t\\tWelcome to Blackjack!\\n\";\n", + "numPlayers = 0;\n", + "while (numPlayers < 1 or numPlayers > 7):\n", + " print \"How many players? (1 - 7): \";\n", + " numPlayers = int(raw_input())\n", + "\n", + "names = []\n", + "name = ''\n", + "for i in range(numPlayers):\n", + " print \"Enter player name: \";\n", + " name = raw_input()\n", + " names.append(name); \n", + "\n", + "print ''\n", + "#the game loop\n", + "aGame = Game(names);\n", + "again = 'y'\n", + "while (again != 'n' and again != 'N'):\n", + " aGame.Play();\n", + " print \"\\nDo you want to play again? (Y/N): \",\n", + " again = raw_input()\n", + "\n", + "#overloads << operator so Card object can be sent to cout\n", + "def print_(aCard):\n", + " RANKS = [\"0\", \"A\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\",\"10\", \"J\", \"Q\", \"K\"]\n", + " SUITS = [\"c\", \"d\", \"h\", \"s\"]\n", + " if (aCard.m_IsFaceUp):\n", + " print RANKS[aCard.m_Rank] , SUITS[aCard.m_Suit];\n", + " else:\n", + " print \"XX\";\n", + " \n", + "\n", + "def print__(aGenericPlayer):\n", + " print aGenericPlayer.m_Name\n", + " pCard = []\n", + " if (not aGenericPlayer.m_Cards):\n", + " for pCard in aGenericPlayer.m_Cards:\n", + " print pCard\n", + " \n", + " if (aGenericPlayer.GetTotal() != 0):\n", + " print \"(\" , aGenericPlayer.GetTotal() , \")\";\n", + " else:\n", + " print \"<empty>\";" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "ename": "StdinNotImplementedError", + "evalue": "raw_input was called, but this frontend does not support stdin.", + "output_type": "pyerr", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mStdinNotImplementedError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m<ipython-input-11-33b9c51ff816>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 63\u001b[0m \u001b[1;32mwhile\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mnumPlayers\u001b[0m \u001b[1;33m<\u001b[0m \u001b[1;36m1\u001b[0m \u001b[1;32mor\u001b[0m \u001b[0mnumPlayers\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m7\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 64\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"How many players? (1 - 7): \"\u001b[0m\u001b[1;33m;\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 65\u001b[1;33m \u001b[0mnumPlayers\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mraw_input\u001b[0m\u001b[1;33m(\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 66\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 67\u001b[0m \u001b[0mnames\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m/home/jay/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/zmq/ipkernel.pyc\u001b[0m in \u001b[0;36m<lambda>\u001b[1;34m(prompt)\u001b[0m\n\u001b[0;32m 343\u001b[0m \u001b[0mraw_input\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mlambda\u001b[0m \u001b[0mprompt\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m''\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_raw_input\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mprompt\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mident\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mparent\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 344\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 345\u001b[1;33m \u001b[0mraw_input\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mlambda\u001b[0m \u001b[0mprompt\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m''\u001b[0m \u001b[1;33m:\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_no_raw_input\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 346\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 347\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mpy3compat\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mPY3\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m/home/jay/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/zmq/ipkernel.pyc\u001b[0m in \u001b[0;36m_no_raw_input\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 686\u001b[0m \"\"\"Raise StdinNotImplentedError if active frontend doesn't support\n\u001b[0;32m 687\u001b[0m stdin.\"\"\"\n\u001b[1;32m--> 688\u001b[1;33m raise StdinNotImplementedError(\"raw_input was called, but this \"\n\u001b[0m\u001b[0;32m 689\u001b[0m \"frontend does not support stdin.\") \n\u001b[0;32m 690\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mStdinNotImplementedError\u001b[0m: raw_input was called, but this frontend does not support stdin." + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\t\tWelcome to Blackjack!\n", + "\n", + "How many players? (1 - 7): \n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Beginning_C++_through_game_programming/ch2.ipynb b/Beginning_C++_through_game_programming/ch2.ipynb new file mode 100755 index 00000000..ff66a26a --- /dev/null +++ b/Beginning_C++_through_game_programming/ch2.ipynb @@ -0,0 +1,238 @@ +{ + "metadata": { + "name": "ch2" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": "Chapter 2 : Truth, Branching, and the Game Loop: Guess My Number" + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "Example 2.1 page no : 41" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\nScore Rater\nDemonstrates the if statement\n'''\n\nif (True):\n print \"This is always displayed.\\n\\n\";\n\nif (False):\n print \"This is never displayed.\\n\\n\";\nscore = 1000;\nif (score):\n print \"At least you didn't score zero.\\n\\n\";\n\nif (score >= 250):\n print \"You scored 250 or more. Decent.\\n\\n\";\n\nif (score >= 500):\n print \"You scored 500 or more. Nice.\\n\\n\";\nif (score >= 1000):\n print \"You scored 1000 or more. Impressive!\\n\";", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "This is always displayed.\n\n\nAt least you didn't score zero.\n\n\nYou scored 250 or more. Decent.\n\n\nYou scored 500 or more. Nice.\n\n\nYou scored 1000 or more. Impressive!\n\n" + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "Example 2.2 page no :46" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\nScore Rater 2.0\nDemonstrates an else clause\n'''\n\nprint \"Enter your score: \";\nscore = 1500 #int(raw_input())\nif (score >= 1000):\n print \"You scored 1000 or more. Impressive!\\n\";\nelse:\n print \"You scored less than 1000.\\n\";", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Enter your score: \nYou scored 1000 or more. Impressive!\n\n" + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "Example 2.3 page no : 49" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\n// Score Rater 3.0\n// Demonstrates if else-if else suite\n'''\n\n\nprint \"Enter your score: \";\nscore = 1500 #int(raw_input())\n\nif (score >= 1000):\n print \"You scored 1000 or more. Impressive!\\n\";\nelif (score >= 500):\n print \"You scored 500 or more. Nice.\\n\";\nelif (score >= 250):\n print \"You scored 250 or more. Decent.\\n\";\nelse:\n print \"You scored less than 250. Nothing to brag about.\\n\";", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Enter your score: \nYou scored 1000 or more. Impressive!\n\n" + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 2.4 page no : 53" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\n// Menu Chooser\n// Demonstrates the switch statement\n'''\n\nprint \"Difficulty Levels\\n\\n\";\nprint \"1 - Easy\\n\";\nprint \"2 - Normal\\n\";\nprint \"3 - Hard\\n\\n\";\n\nprint \"Choice: \";\nchoice = 2 #int(raw_input())\nif choice==1:\n print \"You picked Easy.\\n\";\nelif choice==2: \n print \"You picked Normal.\\n\";\nelif choice==3:\n \"You picked Hard.\\n\";\nelse: \n \"You made an illegal choice.\\n\";", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Difficulty Levels\n\n\n1 - Easy\n\n2 - Normal\n\n3 - Hard\n\n\nChoice: \nYou picked Normal.\n\n" + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 2.5 page no : 55" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\nPlay Again\nDemonstrates while loops\n'''\nchoices = ['y','y','n']\nagain = 'y'\ni = 0\nwhile (again == 'y'):\n print \"\\n**Played an exciting game**\";\n print \"\\nDo you want to play again? (y/n): \",\n again = choices[i] #raw_input()\n i += 1\n\nprint \"\\nOkay, bye.\";", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "\n**Played an exciting game**\n\nDo you want to play again? (y/n): \n**Played an exciting game**\n\nDo you want to play again? (y/n): \n**Played an exciting game**\n\nDo you want to play again? (y/n): \nOkay, bye.\n" + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 2.6 page no : 57" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\nPlay Again\nDemonstrates while loops\n'''\nchoices = ['y','y','n']\ni = 0\nagain = 'y'\nwhile (again == 'y'):\n print \"\\n**Played an exciting game**\";\n print \"\\nDo you want to play again? (y/n): \",\n again = choices[i] #raw_input()\n i += 1\n\nprint \"\\nOkay, bye.\";", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "\n**Played an exciting game**\n\nDo you want to play again? (y/n): \n**Played an exciting game**\n\nDo you want to play again? (y/n): \n**Played an exciting game**\n\nDo you want to play again? (y/n): \nOkay, bye.\n" + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 2.7 page no :59" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\n// Finicky Counter\n// Demonstrates break and continue statements\n'''\ncount = 0;\nwhile (True):\n count += 1;\n #end loop if count is greater than 10\n if (count > 10):\n break;\n #skip the number 5\n if (count == 5):\n continue;\n print count", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "1\n2\n3\n4\n6\n7\n8\n9\n10\n" + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 2.8 page no : 63" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\n// Designers Network\n// Demonstrates logical operators\n'''\n\nprint \"\\tGame Designer's Network\\n\";\nsuccess = False\nwhile not success:\n print \"\\nUsername: \";\n username = 'guest' #raw_input()\n print \"Password: \";\n password = 'guest' #raw_input()\n if (username == \"S.Meier\" and password == \"civilization\"):\n print \"\\nHey, Sid.\";\n success = True;\n elif (username == \"S.Miyamoto\" and password == \"mariobros\"):\n print \"\\nWhat's up, Shigeru?\";\n success = True;\n elif (username == \"W.Wright\" and password == \"thesims\"):\n print \"\\nHow goes it, Will?\";\n success = True;\n elif (username == \"guest\" or password == \"guest\"):\n print \"\\nWelcome, guest.\";\n success = True;\n else:\n print \"\\nYour login failed.\";\n success = False;", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "\tGame Designer's Network\n\n\nUsername: \nPassword: \n\nWelcome, guest.\n" + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 2.9 page no : 68" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\n// Die Roller\n// Demonstrates generating random numbers\n'''\nimport random\n\nrandomNumber = random.random()*100;\n#seed random number generator\n#generate random number\ndie = int(randomNumber % 6) + 1; # get a number between 1 and 6\nprint \"You rolled a \" , die", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "You rolled a 4\n" + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 2.10 page no : 74" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\nGuess My Number\nThe classic number guessing game\n'''\nimport random\nsecretNumber = int(random.random()*100) % 10 + 1;\ntries = 0;\n#seed random number generator\n# random number between 1 and 100\nprint \"\\tWelcome to Guess My Number\\n\\n\";\nguesses = [0,1,2,3,4,5,6,7,8,9,10]\ni = 0\nwhile True:\n print \"Enter a guess: \";\n guess = guesses[i] #int(raw_input())\n i += 1\n tries += 1\n if (guess > secretNumber):\n print \"Too high!\\n\\n\";\n elif (guess < secretNumber):\n print \"Too low!\\n\\n\";\n else:\n print \"\\nThat's it! You got it in \" , tries , \" guesses!\\n\";\n break", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "\tWelcome to Guess My Number\n\n\nEnter a guess: \nToo low!\n\n\nEnter a guess: \nToo low!\n\n\nEnter a guess: \nToo low!\n\n\nEnter a guess: \nToo low!\n\n\nEnter a guess: \nToo low!\n\n\nEnter a guess: \nToo low!\n\n\nEnter a guess: \n\nThat's it! You got it in 7 guesses!\n\n" + } + ], + "prompt_number": 11 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "", + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Beginning_C++_through_game_programming/ch3.ipynb b/Beginning_C++_through_game_programming/ch3.ipynb new file mode 100755 index 00000000..ee604f70 --- /dev/null +++ b/Beginning_C++_through_game_programming/ch3.ipynb @@ -0,0 +1,442 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 3 : For Loops, Strings, and Arrays: Word Jumble" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 3.1 page no :83" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "// Counter\n", + "// Demonstrates for loops\n", + "'''\n", + "print \"Counting forward:\\n\";\n", + "for i in range(10):\n", + " print i ,\n", + "print \"\\n\\nCounting backward:\\n\";\n", + "for i in range(1,10,-1):\n", + " print i,\n", + "\n", + "print \"\\n\\nCounting by fives:\\n\";\n", + "for i in range(0,51,5):\n", + " print i,\n", + " \n", + "print \"\\n\\nCounting with null statements:\\n\";\n", + "count = 0;\n", + "while ( count < 10 ):\n", + " print count ,\n", + " count += 1\n", + "\n", + "print \"\\n\\nCounting with nested for loops:\\n\";\n", + "ROWS = 5;\n", + "COLUMNS = 3;\n", + "for i in range(ROWS):\n", + " for j in range(COLUMNS):\n", + " print i , \",\" , j ," + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Counting forward:\n", + "\n", + "0 1 2 3 4 5 6 7 8 9 \n", + "\n", + "Counting backward:\n", + "\n", + "\n", + "\n", + "Counting by fives:\n", + "\n", + "0 5 10 15 20 25 30 35 40 45 50 \n", + "\n", + "Counting with null statements:\n", + "\n", + "0 1 2 3 4 5 6 7 8 9 \n", + "\n", + "Counting with nested for loops:\n", + "\n", + "0 , 0 0 , 1 0 , 2 1 , 0 1 , 1 1 , 2 2 , 0 2 , 1 2 , 2 3 , 0 3 , 1 3 , 2 4 , 0 4 , 1 4 , 2\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 3.2 page no : 90" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "// String Tester\n", + "// Demonstrates string objects\n", + "'''\n", + "word1 = \"Game\";\n", + "word2 =\"Over\"\n", + "word3 = '!'\n", + "phrase = word1 + \" \" + word2 + word3;\n", + "print \"The phrase is: \" , phrase , \"\\n\";\n", + "print \"The phrase has \" , len(phrase) , \" characters in it.\\n\";\n", + "print \"The character at position 0 is: \" , phrase[0] , \"\\n\\n\";\n", + "print \"Changing the character at position 0.\\n\";\n", + "#phrase[0] = 'L';\n", + "print \"The phrase is now: \" , phrase , \"\\n\"\n", + "for i in range(len(phrase)):\n", + " print \"Character at position \" , i , \" is: \" , phrase[i] \n", + "\n", + "print \"\\nThe sequence 'Over' begins at location \";\n", + "print phrase.find(\"Over\") \n", + "if (\"eggplant\" not in phrase):\n", + " print \"'eggplant' is not in the phrase.\\n\\n\";\n", + "\n", + "# Python does not support string erase function.\n", + "#phrase.erase(4, 5); \n", + "print \"The phrase is now: \" , phrase \n", + "#phrase.erase(4);\n", + "print \"The phrase is now: \" , phrase \n", + "#phrase.erase();\n", + "print \"The phrase is now: \" , phrase \n", + "if (phrase==''):\n", + " print \"\\nThe phrase is no more.\\n\";" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The phrase is: Game Over! \n", + "\n", + "The phrase has 10 characters in it.\n", + "\n", + "The character at position 0 is: G \n", + "\n", + "\n", + "Changing the character at position 0.\n", + "\n", + "The phrase is now: Game Over! \n", + "\n", + "Character at position 0 is: G\n", + "Character at position 1 is: a\n", + "Character at position 2 is: m\n", + "Character at position 3 is: e\n", + "Character at position 4 is: \n", + "Character at position 5 is: O\n", + "Character at position 6 is: v\n", + "Character at position 7 is: e\n", + "Character at position 8 is: r\n", + "Character at position 9 is: !\n", + "\n", + "The sequence 'Over' begins at location \n", + "5\n", + "'eggplant' is not in the phrase.\n", + "\n", + "\n", + "The phrase is now: Game Over!\n", + "The phrase is now: Game Over!\n", + "The phrase is now: Game Over!\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 3.3 page no : 97" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "// Heros Inventory\n", + "// Demonstrates arrays\n", + "'''\n", + "MAX_ITEMS = 10;\n", + "inventory = [];\n", + "\n", + "inventory.append(\"sword\")\n", + "inventory.append(\"armor\")\n", + "inventory.append(\"shield\")\n", + "print \"Your items:\\n\";\n", + "for i in range(len(inventory)):\n", + " print inventory[i]\n", + "\n", + "print \"\\nYou trade your sword for a battle axe.\";\n", + "inventory[0] = \"battle axe\";\n", + "print \"\\nYour items:\\n\";\n", + "for i in range(len(inventory)):\n", + " print inventory[i]\n", + "\n", + "print \"\\nThe item name '\" , inventory[0] , \"' has \",\n", + "print len(inventory[0]) , \" letters in it.\\n\";\n", + "print \"\\nYou find a healing potion.\";\n", + "if (len(inventory) < MAX_ITEMS):\n", + " inventory.append(\"healing potion\")\n", + "else:\n", + " print \"You have too many items and can't carry another.\";\n", + "print \"\\nYour items:\\n\";\n", + "for i in range(len(inventory)):\n", + " print inventory[i]\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Your items:\n", + "\n", + "sword\n", + "armor\n", + "shield\n", + "\n", + "You trade your sword for a battle axe.\n", + "\n", + "Your items:\n", + "\n", + "battle axe\n", + "armor\n", + "shield\n", + "\n", + "The item name ' battle axe ' has 10 letters in it.\n", + "\n", + "\n", + "You find a healing potion.\n", + "\n", + "Your items:\n", + "\n", + "battle axe\n", + "armor\n", + "shield\n", + "healing potion\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 3.4 page no : 104" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "// Tic-Tac-Toe Board\n", + "// Demonstrates multidimensional arrays\n", + "'''\n", + "ROWS = 3;\n", + "COLUMNS = 3;\n", + "board = [['O', 'X', 'O'],[' ', 'X', 'X'],['X', 'O', 'O']]\n", + "print \"Here's the tic-tac-toe board:\\n\";\n", + "for i in range(ROWS):\n", + " for j in range(COLUMNS):\n", + " print board[i][j],\n", + " print ''\n", + "\n", + "print \"\\n'X' moves to the empty location.\\n\\n\";\n", + "board[1][0] = 'X';\n", + "print \"Now the tic-tac-toe board is:\\n\";\n", + "for i in range(ROWS):\n", + " for j in range(COLUMNS):\n", + " print board[i][j],\n", + " print ''\n", + "print \"\\n'X' wins!\";" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Here's the tic-tac-toe board:\n", + "\n", + "O X O \n", + " X X \n", + "X O O \n", + "\n", + "'X' moves to the empty location.\n", + "\n", + "\n", + "Now the tic-tac-toe board is:\n", + "\n", + "O X O \n", + "X X X \n", + "X O O \n", + "\n", + "'X' wins!\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 3.5 page no : 107" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "# Word Jumble\n", + "# The classic word jumble game where the player can ask for a hint\n", + "'''\n", + "fields = ['WORD', 'HINT', 'NUM_FIELDS']\n", + "NUM_WORDS = 5;\n", + "WORDS = [ [\"wall\", \"Do you feel you're banging your head against something?\"],\n", + " [\"glasses\", \"These might help you see the answer.\"],\n", + " [\"labored\", \"Going slowly, is it?\"],\n", + " [\"persistent\", \"Keep at it.\"],\n", + " [\"jumble\", \"It's what the game is all about.\"]]\n", + "\n", + "class difficulty:\n", + " EASY = 0\n", + " MEDIUM = 1\n", + " HARD = 2\n", + " NUM_DIFF_LEVELS = 3\n", + " \n", + "print \"There are \" , difficulty.NUM_DIFF_LEVELS ,\" difficulty levels.\"\n", + "\n", + "import random\n", + "#srand(static_cast<unsigned int>(time(0)));\n", + "choice = (int(random.random() * 10) % NUM_WORDS);\n", + "theWord = WORDS[choice][0]; # word to guess\n", + "theHint = WORDS[choice][1]; # hint for word\n", + "jumble = theWord; # jumbled version of word\n", + "length = len(jumble)\n", + "for i in range(length):\n", + " index1 = (int(random.random() * 10) % length);\n", + " index2 = (int(random.random() * 10) % length);\n", + " temp = list(jumble)\n", + " temp[index1],temp[index2] = temp[index2],temp[index1]\n", + " jumble = ''.join(temp)\n", + "\n", + "print \"\\t\\t\\tWelcome to Word Jumble!\\n\\n\";\n", + "print \"Unscramble the letters to make a word.\\n\";\n", + "print \"Enter 'hint' for a hint.\\n\";\n", + "print \"Enter 'quit' to quit the game.\\n\\n\";\n", + "print \"The jumble is: \" , jumble;\n", + "\n", + "print \"Your guess: \";\n", + "guess = raw_input()\n", + "\n", + "while ((guess != theWord) and (guess != \"quit\")):\n", + " if (guess == \"hint\"):\n", + " print theHint;\n", + " else:\n", + " print \"Sorry, that's not it.\";\n", + " print \"\\n\\nYour guess: \";\n", + " guess = raw_input()\n", + "\n", + "if (guess == theWord):\n", + " print \"\\nThat's it! You guessed it!\\n\";\n", + "\n", + "print \"\\nThanks for playing.\\n\";\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "There are 3 difficulty levels.\n", + "\t\t\tWelcome to Word Jumble!\n", + "\n", + "\n", + "Unscramble the letters to make a word.\n", + "\n", + "Enter 'hint' for a hint.\n", + "\n", + "Enter 'quit' to quit the game.\n", + "\n", + "\n", + "The jumble is: gasslse\n", + "Your guess: \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "glasses\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "That's it! You guessed it!\n", + "\n", + "\n", + "Thanks for playing.\n", + "\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Beginning_C++_through_game_programming/ch4.ipynb b/Beginning_C++_through_game_programming/ch4.ipynb new file mode 100755 index 00000000..29da32f0 --- /dev/null +++ b/Beginning_C++_through_game_programming/ch4.ipynb @@ -0,0 +1,393 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 4 : The Standard Template Library: Hangman" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 4.1 page no : 118" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "// Hero's Inventory 2.0\n", + "// Demonstrates vectors\n", + "'''\n", + "\n", + "inventory = []\n", + "inventory.append(\"sword\");\n", + "inventory.append(\"armor\");\n", + "inventory.append(\"shield\");\n", + "print \"You have \" , len(inventory) , \" items.\";\n", + "print \"\\nYour items:\";\n", + "for i in inventory:\n", + " print i\n", + "\n", + "print \"\\nYou trade your sword for a battle axe.\";\n", + "inventory[0] = \"battle axe\";\n", + "print \"\\nYour items:\\n\";\n", + "for i in inventory:\n", + " print i\n", + "\n", + "print \"\\nThe item name '\" , inventory[0] , \"' has \",\n", + "print len(inventory[0]) , \" letters in it.\";\n", + "print \"\\nYour shield is destroyed in a fierce battle.\";\n", + "inventory.pop();\n", + "print \"\\nYour items:\";\n", + "for i in inventory:\n", + " print i\n", + "\n", + "print \"\\nYou were robbed of all of your possessions by a thief.\";\n", + "inventory = []\n", + "if (not inventory):\n", + " print \"\\nYou have nothing.\";\n", + "else:\n", + " print \"\\nYou have at least one item.\\n\";" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "You have 3 items.\n", + "\n", + "Your items:\n", + "sword\n", + "armor\n", + "shield\n", + "\n", + "You trade your sword for a battle axe.\n", + "\n", + "Your items:\n", + "\n", + "battle axe\n", + "armor\n", + "shield\n", + "\n", + "The item name ' battle axe ' has 10 letters in it.\n", + "\n", + "Your shield is destroyed in a fierce battle.\n", + "\n", + "Your items:\n", + "battle axe\n", + "armor\n", + "\n", + "You were robbed of all of your possessions by a thief.\n", + "\n", + "You have nothing.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 4.2 page no : 124" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "// Hero's Inventory 3.0\n", + "// Demonstrates iterators\n", + "'''\n", + "\n", + "inventory = []\n", + "inventory.append(\"sword\");\n", + "inventory.append(\"armor\");\n", + "inventory.append(\"shield\");\n", + "print \"You have \" , len(inventory) , \" items.\";\n", + "print \"\\nYour items:\";\n", + "for i in inventory:\n", + " print i\n", + "\n", + "print \"\\nYou trade your sword for a battle axe.\";\n", + "inventory[0] = \"battle axe\";\n", + "print \"\\nYour items:\\n\";\n", + "for i in inventory:\n", + " print i\n", + "\n", + "print \"\\nThe item name '\" , inventory[0] , \"' has \",\n", + "print len(inventory[0]) , \" letters in it.\";\n", + "\n", + "print \"You recover a crossbow from a slain enemy.\";\n", + "inventory.insert(0,\"crossbow\");\n", + "print \"Your items:\";\n", + "for i in inventory:\n", + " print i\n", + " \n", + "print \"\\nYour shield is destroyed in a fierce battle.\";\n", + "inventory.pop();\n", + "print \"\\nYour items:\";\n", + "for i in inventory:\n", + " print i" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "You have 3 items.\n", + "\n", + "Your items:\n", + "sword\n", + "armor\n", + "shield\n", + "\n", + "You trade your sword for a battle axe.\n", + "\n", + "Your items:\n", + "\n", + "battle axe\n", + "armor\n", + "shield\n", + "\n", + "The item name ' battle axe ' has 10 letters in it.\n", + "You recover a crossbow from a slain enemy.\n", + "Your items:\n", + "crossbow\n", + "battle axe\n", + "armor\n", + "shield\n", + "\n", + "Your shield is destroyed in a fierce battle.\n", + "\n", + "Your items:\n", + "crossbow\n", + "battle axe\n", + "armor\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 4.3 page no : 132" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "// High Scores\n", + "// Demonstrates algorithms\n", + "'''\n", + "print \"Creating a list of scores.\";\n", + "scores = []\n", + "scores.append(1500);\n", + "scores.append(3500);\n", + "scores.append(7500);\n", + "print \"\\nHigh Scores:\";\n", + "for i in scores:\n", + " print i\n", + "\n", + "print \"\\nFinding a score.\";\n", + "\n", + "print \"\\nEnter a score to find: \";\n", + "score = 3500 #int(raw_input())\n", + "iter = score in scores\n", + "if (iter):\n", + " print \"Score found.\";\n", + "else:\n", + " print \"Score not found.\";\n", + "\n", + "print \"\\nRandomizing scores.\";\n", + "import random\n", + "for i in range(len(scores)):\n", + " scores[i] = int(random.random() * 10000) \n", + "\n", + "print \"\\nHigh Scores:\\n\";\n", + "for i in scores:\n", + " print i\n", + " \n", + "print \"\\nSorting scores.\";\n", + "scores.sort()\n", + "print \"\\nHigh Scores:\\n\";\n", + "for i in scores:\n", + " print i" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating a list of scores.\n", + "\n", + "High Scores:\n", + "1500\n", + "3500\n", + "7500\n", + "\n", + "Finding a score.\n", + "\n", + "Enter a score to find: \n", + "Score found.\n", + "\n", + "Randomizing scores.\n", + "\n", + "High Scores:\n", + "\n", + "6658\n", + "5396\n", + "8522\n", + "\n", + "Sorting scores.\n", + "\n", + "High Scores:\n", + "\n", + "5396\n", + "6658\n", + "8522\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 4.4 page no: 142" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "// Hangman\n", + "// The classic game of hangman\n", + "'''\n", + "#setup\n", + "MAX_WRONG = 8;\n", + "#maximum number of incorrect guesses allowed\n", + "words = [] # collection of possible words to guess\n", + "words.append(\"GUESS\");\n", + "words.append(\"HANGMAN\");\n", + "words.append(\"DIFFICULT\");\n", + "THE_WORD = words[0];\n", + "wrong = 0;\n", + "soFar = ''\n", + "for i in range(len(THE_WORD)):\n", + " soFar += '-'\n", + "\n", + "used = \"\";\n", + "\n", + "print \"Welcome to Hangman. Good luck!\\n\";\n", + "# main loop\n", + "while ((wrong < MAX_WRONG) and (soFar != THE_WORD)):\n", + " print \"\\n\\nYou have \" , (MAX_WRONG - wrong);\n", + " print \" incorrect guesses left.\";\n", + " print \"\\nYou've used the following letters:\\n\" , used \n", + " print \"\\nSo far, the word is:\" , soFar\n", + " print \"\\nEnter your guess: \";\n", + " guess = raw_input()\n", + " guess = guess.upper() #make uppercase since secret word in uppercase\n", + " while guess in used:\n", + " print \"\\nYou've already guessed \" , guess \n", + " print \"Enter your guess: \";\n", + " guess = 'GUESS' #raw_input()\n", + " guess = guess.upper()\n", + " used += guess;\n", + " soFar = ''\n", + " if (guess in THE_WORD):\n", + " print \"That's right! \" , guess , \" is in the word.\";\n", + " #update soFar to include newly guessed letter\n", + " for i in range(len(THE_WORD)):\n", + " if (THE_WORD[i] == guess):\n", + " soFar += guess\n", + " else:\n", + " print \"Sorry, \" , guess , \" isn't in the word.\";\n", + " wrong += 1\n", + " #shut down\n", + " if (wrong == MAX_WRONG):\n", + " print \"\\nYou've been hanged!\";\n", + " else:\n", + " print \"\\nYou guessed it!\";\n", + " print \"\\nThe word was \" , THE_WORD " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "ename": "StdinNotImplementedError", + "evalue": "raw_input was called, but this frontend does not support stdin.", + "output_type": "pyerr", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mStdinNotImplementedError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m<ipython-input-7-9b09a3413260>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 27\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"\\nSo far, the word is:\"\u001b[0m \u001b[1;33m,\u001b[0m \u001b[0msoFar\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 28\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"\\nEnter your guess: \"\u001b[0m\u001b[1;33m;\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 29\u001b[1;33m \u001b[0mguess\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mraw_input\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 30\u001b[0m \u001b[0mguess\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mguess\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mupper\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;31m#make uppercase since secret word in uppercase\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 31\u001b[0m \u001b[1;32mwhile\u001b[0m \u001b[0mguess\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mused\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m/home/jay/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/zmq/ipkernel.pyc\u001b[0m in \u001b[0;36m<lambda>\u001b[1;34m(prompt)\u001b[0m\n\u001b[0;32m 343\u001b[0m \u001b[0mraw_input\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mlambda\u001b[0m \u001b[0mprompt\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m''\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_raw_input\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mprompt\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mident\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mparent\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 344\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 345\u001b[1;33m \u001b[0mraw_input\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mlambda\u001b[0m \u001b[0mprompt\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m''\u001b[0m \u001b[1;33m:\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_no_raw_input\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 346\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 347\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mpy3compat\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mPY3\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m/home/jay/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/zmq/ipkernel.pyc\u001b[0m in \u001b[0;36m_no_raw_input\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 686\u001b[0m \"\"\"Raise StdinNotImplentedError if active frontend doesn't support\n\u001b[0;32m 687\u001b[0m stdin.\"\"\"\n\u001b[1;32m--> 688\u001b[1;33m raise StdinNotImplementedError(\"raw_input was called, but this \"\n\u001b[0m\u001b[0;32m 689\u001b[0m \"frontend does not support stdin.\") \n\u001b[0;32m 690\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mStdinNotImplementedError\u001b[0m: raw_input was called, but this frontend does not support stdin." + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Welcome to Hangman. Good luck!\n", + "\n", + "\n", + "\n", + "You have 8\n", + " incorrect guesses left.\n", + "\n", + "You've used the following letters:\n", + "\n", + "\n", + "So far, the word is: -----\n", + "\n", + "Enter your guess: \n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Beginning_C++_through_game_programming/ch5.ipynb b/Beginning_C++_through_game_programming/ch5.ipynb new file mode 100755 index 00000000..923fa8d5 --- /dev/null +++ b/Beginning_C++_through_game_programming/ch5.ipynb @@ -0,0 +1,196 @@ +{ + "metadata": { + "name": "ch5" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": "chapter 5 : Functions: Mad Lib" + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 5.1 page no : 152" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\n// Instructions\n// Demonstrates writing new functions\n'''\n\n# function prototype (declaration)\ndef instructions():\n print \"Welcome to the most fun you've ever had with text!\\n\";\n print \"Here's how to play the game. . .\\n\";\n\ninstructions();", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Welcome to the most fun you've ever had with text!\n\nHere's how to play the game. . .\n\n" + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 5.2 page no : 156" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\n// Yes or No\n// Demonstrates return values and parameters\n'''\n\ndef askYesNo1():\n while True:\n print \"Please enter 'y' or 'n' : \",\n response1 = 'y' #raw_input()\n if (response1 == 'y' or response1 == 'n'):\n return response1\n\ndef askYesNo2(question):\n while True:\n print question ,\n response1 = 'n' #raw_input()\n if (response1 == 'y' or response1 == 'n'):\n return response1\n\n\nanswer1 = askYesNo1();\nprint \"Thanks for answering: \" , answer1 \nanswer2 = askYesNo2(\"Do you wish to save your game?\");\nprint \"Thanks for answering: \" , answer2 ", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Please enter 'y' or 'n' : Thanks for answering: y\nDo you wish to save your game? Thanks for answering: n\n" + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 5.3 page no : 162" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\n# Scoping\n# Demonstrates scopes\n'''\ndef func():\n var = -5; # local variable in func()\n print \"In func() var is: \" , var \n\nvar = 5 # local variable in main()\nprint \"In main() var is: \" , var\nfunc();\nprint \"Back in main() var is: \" , var\nprint \"In main() in a new scope var is: \" , var\nprint \"Creating new var in new scope.\";\nvar = 10; # variable in new scope, hides other variable named var\nprint \"In main() in a new scope var is: \" , var \n\nprint \"At end of main() var created in new scope no longer exists.\";\nprint \"At end of main() var is: \" , var ", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "In main() var is: 5\nIn func() var is: -5\nBack in main() var is: 5\nIn main() in a new scope var is: 5\nCreating new var in new scope.\nIn main() in a new scope var is: 10\nAt end of main() var created in new scope no longer exists.\nAt end of main() var is: 10\n" + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 5.4 page no : 167" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\nglobal access of variable\n'''\n\nglob = 10; # global variable\n\ndef access_global():\n global glob\n print \"In access_global() glob is: \" , glob\n\ndef hide_global():\n glob = 0 # hide global variable glob\n print \"In hide_global() glob is: \" , glob\n\ndef change_global():\n glob = -10; # change global variable glob\n print \"In change_global() glob is: \" , glob\n\n\nprint \"In main() glob is: \" , glob\naccess_global();\nhide_global();\nprint \"In main() glob is: \" , glob\nchange_global();\nprint \"In main() glob is: \" , glob", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "In main() glob is: 10\nIn access_global() glob is: 10\nIn hide_global() glob is: 0\nIn main() glob is: 10\nIn change_global() glob is: -10\nIn main() glob is: 10\n" + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 5.5 page no : 172" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\n// Give Me a Number\n// Demonstrates default function arguments\n'''\ndef askNumber(high,low=1):\n a = high + 2\n while True:\n print \"Please enter a number\" , \" (\" , low , \" - \" , high , \"): \"\n num = a #int(raw_input())\n if (num > high or num < low):\n return num\n\n\nnumber = askNumber(5);\nprint \"Thanks for entering: \" , number\nnumber = askNumber(10, 5);\nprint \"Thanks for entering: \" , number", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Please enter a number ( 1 - 5 ): \nThanks for entering: 7\nPlease enter a number ( 5 - 10 ): \nThanks for entering: 12\n" + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 5.6 page no : 175" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\n// Triple\n'''\n\ndef triple(number):\n return (number * 3);\n\ndef triple1(text):\n return (text + text + text);\n\nprint \"Tripling 5: \" , triple(5) \nprint \"Tripling 'gamer': \" , triple1(\"gamer\");", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Tripling 5: 15\nTripling 'gamer': gamergamergamer\n" + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 5.7 page no : 178" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\n// Taking Damage\n// Demonstrates function inlining\n'''\n\ndef radiation( health):\n return (health / 2);\n\nhealth = 80;\nprint \"Your health is \" , health \nhealth = radiation(health);\nprint \"After radiation exposure your health is \" , health \nhealth = radiation(health);\nprint \"After radiation exposure your health is \" , health \nhealth = radiation(health);\nprint \"After radiation exposure your health is \" , health ", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Your health is 80\nAfter radiation exposure your health is 40\nAfter radiation exposure your health is 20\nAfter radiation exposure your health is 10\n" + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 5.8 page no : 181" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\n// Mad-Lib\n// Creates a story based on user input\n'''\n\ndef askText(prompt):\n print prompt ,\n a = raw_input()\n return a\n\ndef askNumber(prompt):\n print prompt ,\n return int(raw_input())\n\ndef tellStory(name, noun, number, bodyPart, verb):\n print \"\\nHere's your story:\";\n print \"The famous explorer \" ,;\n print name ,\n print \" had nearly given up a life-long quest to find\",\n print \"The Lost City of \",\n print noun,\n print \" when one day, the \",\n print noun,\n print \" found the explorer.\"\n print \"Surrounded by \",\n print number,\n print \" \" , noun,\n print \", a tear came to \",\n print name , \"'s \",\n print bodyPart , \".\"\n print \"After all this time, the quest was finally over. \",\n print \"And then, the \",\n print noun \n print \"promptly devoured \",\n print name , \". \"\n print \"The moral of the story? Be careful what you \",\n print verb,\n print \" for.\",\n\n\nprint \"Welcome to Mad Lib.\\n\";\nprint \"Answer the following questions to help create a new story.\";\nname = 'jay' #askText(\"Please enter a name: \");\nnoun = 'go' #askText(\"Please enter a plural noun: \");\nnumber = 10 #askNumber(\"Please enter a number: \");\nbodyPart = 'nothing' #askText(\"Please enter a body part: \");\nverb = 'verb' #askText(\"Please enter a verb: \");\ntellStory(name, noun, number, bodyPart, verb);\n\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Welcome to Mad Lib.\n\nAnswer the following questions to help create a new story.\n\nHere's your story:\nThe famous explorer jay had nearly given up a life-long quest to find The Lost City of go when one day, the go found the explorer.\nSurrounded by 10 go , a tear came to jay 's nothing .\nAfter all this time, the quest was finally over. And then, the go\npromptly devoured jay . \nThe moral of the story? Be careful what you verb for.\n" + } + ], + "prompt_number": 9 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "", + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Beginning_C++_through_game_programming/ch6.ipynb b/Beginning_C++_through_game_programming/ch6.ipynb new file mode 100755 index 00000000..d5486321 --- /dev/null +++ b/Beginning_C++_through_game_programming/ch6.ipynb @@ -0,0 +1,141 @@ +{ + "metadata": { + "name": "ch6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 6.1 page no : 188" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\n// Referencing\n// Demonstrates using references\nNote : python does not have reference variable.\n'''\nmyScore = 1000;\nmikesScore = myScore; #create a reference\nprint \"myScore is: \" , myScore\nprint \"mikesScore is: \" , mikesScore \nprint \"Adding 500 to myScore\\n\";\nmyScore += 500;\nprint \"myScore is: \" , myScore\nprint \"mikesScore is: \" , mikesScore\nprint \"Adding 500 to mikesScore\";\nmikesScore += 500;\nprint \"myScore is: \" , myScore \nprint \"mikesScore is: \" , mikesScore", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "myScore is: 1000\nmikesScore is: 1000\nAdding 500 to myScore\n\nmyScore is: 1500\nmikesScore is: 1000\nAdding 500 to mikesScore\nmyScore is: 1500\nmikesScore is: 1500\n" + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 6.2 page no : 192" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\n// Swap\n// Demonstrates passing references to alter argument variables\n'''\ndef badSwap(x,y):\n x,y = y,x\n\ndef goodSwap(x, y):\n x[0],y[0] = y[0],x[0]\n\nmyScore = [1500];\nyourScore = [1000];\nprint \"Original values\";\nprint \"myScore: \" , myScore[0] \nprint \"yourScore: \" , yourScore[0]\nprint \"Calling badSwap()\\n\";\nbadSwap(myScore[0], yourScore[0]);\nprint \"myScore: \" , myScore[0] \nprint \"yourScore: \" , yourScore[0]\nprint \"Calling goodSwap()\\n\";\ngoodSwap(myScore, yourScore);\nprint \"myScore: \" , myScore[0] \nprint \"yourScore: \" , yourScore[0] ,", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Original values\nmyScore: 1500\nyourScore: 1000\nCalling badSwap()\n\nmyScore: 1500\nyourScore: 1000\nCalling goodSwap()\n\nmyScore: 1000\nyourScore: 1500\n" + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 6.3 page no : 196" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\n// Inventory Displayer\n// Demonstrates constant references\n'''\n\ndef display(vec):\n print \"Your items:\";\n for i in vec:\n print i\n\ninventory = []\ninventory.append(\"sword\");\ninventory.append(\"armor\");\ninventory.append(\"shield\");\ndisplay(inventory);", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Your items:\nsword\narmor\nshield\n" + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example : 6.4 page no : 199" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\n// Inventory Referencer\n// Demonstrates returning a reference\n'''\n#returns a reference to a string\n\ndef refToElement(vec,i):\n return vec[i]\n\ninventory = []\ninventory.append(\"sword\");\ninventory.append(\"armor\");\ninventory.append(\"shield\");\n\n#displays string that the returned reference refers to\nprint \"Sending the returned reference to cout:\"\nprint refToElement(inventory, 0) \n#assigns one reference to another -- inexpensive assignment\nprint \"Assigning the returned reference to another reference.\";\nrStr = refToElement(inventory, 1);\nprint \"Sending the new reference to cout:\";\nprint rStr\n#copies a string object -- expensive assignment\nprint \"Assigning the returned reference to a string object.\";\ns = refToElement(inventory, 2);\nprint \"Sending the new string object to cout:\";\nprint s\n#altering the string object through a returned reference\nprint \"Altering an object through a returned reference.\";\nrStr = \"Healing Potion\";\nprint \"Sending the altered object to cout:\";\nprint inventory[1] ", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Sending the returned reference to cout:\nsword\nAssigning the returned reference to another reference.\nSending the new reference to cout:\narmor\nAssigning the returned reference to a string object.\nSending the new string object to cout:\nshield\nAltering an object through a returned reference.\nSending the altered object to cout:\narmor\n" + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 6.5 page no : 205" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\nTic-Tac-Toe\nPlays the game of tic-tac-toe against a human opponent\n'''\n\n\n# global constants\nX = 'X'\nO = 'O'\nEMPTY = ' ';\nTIE = 'T';\nNO_ONE = 'N';\n\ndef instructions():\n print \"Welcome to the ultimate man-machine showdown: Tic-Tac-Toe.\";\n print \"--where human brain is pit against silicon processor\";\n print \"Make your move known by entering a number, 0 - 8. The number\";\n print \"corresponds to the desired board position, as illustrated:\";\n print \"0 | 1 | 2\";\n print \"---------\";\n print \"3 | 4 | 5\\n\"; \n print \"---------\";\n print \"6 | 7 | 8\\n\\n\";\n print \"Prepare yourself, human. The battle is about to begin.\";\n\ndef askYesNo(question):\n response =''\n while (response != 'y' and response != 'n'):\n print question , \" (y/n): \",\n response = raw_input()\n return response;\n\ndef askNumber( question, high, low):\n while True:\n print question , \" (\" , low , \" - \" , high , \"): \",\n number = int(raw_input())\n if (number > high or number < low):\n pass\n else:\n break\n return number;\n\ndef humanPiece():\n global X,O,EMPTY,TIE,NO_ONE\n go_first = askYesNo(\"Do you require the first move?\");\n if (go_first == 'y'):\n print \"Then take the first move. You will need it.\"\n return X;\n else:\n print \"Your bravery will be your undoing. . . I will go first.\";\n return O;\n\ndef opponent( piece):\n global X,O,EMPTY,TIE,NO_ONE\n if (piece == X):\n return O;\n else:\n return X;\n\ndef displayBoard( board):\n print \"\\n\\t\" , board[0] , \" | \" , board[1] , \" | \" , board[2];\n print \"\\t\" , \"---------\";\n print \"\\t\" , board[3] , \" | \" , board[4] , \" | \" , board[5];\n print \"\\t\" , \"---------\";\n print \"\\t\" , board[6] , \" | \" , board[7] , \" | \" , board[8];\n print \"\\n\";\n\ndef winner(board):\n global X,O,EMPTY,TIE,NO_ONE\n # all possible winning rows\n WINNING_ROWS = [ [0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[0,4,6]]\n TOTAL_ROWS = 8;\n # if any winning row has three values that are the same (and not EMPTY),\n # then we have a winner\n for row in range(TOTAL_ROWS):\n if ( (board[WINNING_ROWS[row][0]] != EMPTY) and\n (board[WINNING_ROWS[row][0]] == board[WINNING_ROWS[row][1]]) and\n (board[WINNING_ROWS[row][1]] == board[WINNING_ROWS[row][2]]) ):\n return board[WINNING_ROWS[row][0]];\n # since nobody has won, check for a tie (no empty squares left)\n if EMPTY not in board:\n return TIE;\n return NO_ONE;\n\ndef isLegal(move,board):\n global X,O,EMPTY,TIE,NO_ONE\n return (board[move] == EMPTY);\n\ndef humanMove(board,human):\n global X,O,EMPTY,TIE,NO_ONE\n move = askNumber(\"Where will you move?\", len(board),1);\n '''\n while (not isLegal(move, board)):\n print \"\\nThat square is already occupied, foolish human.\\n\";\n move = askNumber(\"Where will you move?\", len(board),1);\n print move\n ''' \n print \"Fine. . .\\n\";\n return move;\n\ndef computerMove(board, computer):\n global X,O,EMPTY,TIE,NO_ONE\n move = 0;\n found = False;\n #if computer can win on next move, that's the move to make\n while (not found and move < len(board)):\n if (isLegal(move, board)):\n board[move] = computer;\n found = winner(board) == computer;\n board[move] = EMPTY;\n if (not found):\n move += 1\n #otherwise, if human can win on next move, that's the move to make\n if (not found):\n move = 0;\n human = opponent(computer);\n while (not found and move < len(board)):\n if (isLegal(move, board)):\n board[move] = human;\n found = winner(board) == human;\n board[move] = EMPTY;\n if (not found):\n move += 1\n #otherwise, moving to the best open square is the move to make\n if (not found):\n move = 0;\n i = 0;\n BEST_MOVES = [4, 0, 2, 6, 8, 1, 3, 5, 7] #pick best open square\n while (not found and i < len(board)):\n move = BEST_MOVES[i];\n if (isLegal(move, board)):\n found = True;\n i += 1\n print \"I shall take square number \" , move \n return move;\n\ndef announceWinner( winner, computer, human):\n if (winner == computer):\n print winner , \"'s won!\";\n print \"As I predicted, human, I am triumphant once more -- proof\";\n print \"that computers are superior to humans in all regards.\";\n elif (winner == human):\n print winner , \"'s won!\";\n print \"No, no! It cannot be! Somehow you tricked me, human.\";\n print \"But never again! I, the computer, so swear it!\";\n else:\n print \"It's a tie.\\n\";\n print \"You were most lucky, human, and somehow managed to tie me.\\n\";\n print \"Celebrate. . . for this is the best you will ever achieve.\\n\";\n\n\nNUM_SQUARES = 9;\nboard = [EMPTY,EMPTY,EMPTY,EMPTY,EMPTY,EMPTY,EMPTY,EMPTY,EMPTY]\ninstructions();\nhuman = humanPiece();\ncomputer = opponent(human);\nturn = X;\ndisplayBoard(board);\nwhile (winner(board) == NO_ONE):\n if (turn == human):\n move = humanMove(board, human);\n board[move] = human;\n else:\n move = computerMove(board, computer);\n board[move] = computer;\n displayBoard(board);\n turn = opponent(turn);\n\nannounceWinner(winner(board), computer, human);\n\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "ename": "StdinNotImplementedError", + "evalue": "raw_input was called, but this frontend does not support stdin.", + "output_type": "pyerr", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mStdinNotImplementedError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m<ipython-input-5-47d36ba7f5b7>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 154\u001b[0m \u001b[0mboard\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mEMPTY\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mEMPTY\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mEMPTY\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mEMPTY\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mEMPTY\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mEMPTY\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mEMPTY\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mEMPTY\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mEMPTY\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 155\u001b[0m \u001b[0minstructions\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m;\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 156\u001b[1;33m \u001b[0mhuman\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mhumanPiece\u001b[0m\u001b[1;33m(\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 157\u001b[0m \u001b[0mcomputer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mopponent\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mhuman\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m;\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 158\u001b[0m \u001b[0mturn\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mX\u001b[0m\u001b[1;33m;\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m<ipython-input-5-47d36ba7f5b7>\u001b[0m in \u001b[0;36mhumanPiece\u001b[1;34m()\u001b[0m\n\u001b[0;32m 44\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mhumanPiece\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 45\u001b[0m \u001b[1;32mglobal\u001b[0m \u001b[0mX\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mO\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mEMPTY\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mTIE\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mNO_ONE\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 46\u001b[1;33m \u001b[0mgo_first\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0maskYesNo\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Do you require the first move?\"\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 47\u001b[0m \u001b[1;32mif\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mgo_first\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m'y'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 48\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"Then take the first move. You will need it.\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m<ipython-input-5-47d36ba7f5b7>\u001b[0m in \u001b[0;36maskYesNo\u001b[1;34m(question)\u001b[0m\n\u001b[0;32m 29\u001b[0m \u001b[1;32mwhile\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mresponse\u001b[0m \u001b[1;33m!=\u001b[0m \u001b[1;34m'y'\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0mresponse\u001b[0m \u001b[1;33m!=\u001b[0m \u001b[1;34m'n'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 30\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[0mquestion\u001b[0m \u001b[1;33m,\u001b[0m \u001b[1;34m\" (y/n): \"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 31\u001b[1;33m \u001b[0mresponse\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mraw_input\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 32\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mresponse\u001b[0m\u001b[1;33m;\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 33\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m/home/jay/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/zmq/ipkernel.pyc\u001b[0m in \u001b[0;36m<lambda>\u001b[1;34m(prompt)\u001b[0m\n\u001b[0;32m 343\u001b[0m \u001b[0mraw_input\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mlambda\u001b[0m \u001b[0mprompt\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m''\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_raw_input\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mprompt\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mident\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mparent\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 344\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 345\u001b[1;33m \u001b[0mraw_input\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mlambda\u001b[0m \u001b[0mprompt\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m''\u001b[0m \u001b[1;33m:\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_no_raw_input\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 346\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 347\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mpy3compat\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mPY3\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m/home/jay/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/zmq/ipkernel.pyc\u001b[0m in \u001b[0;36m_no_raw_input\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 686\u001b[0m \"\"\"Raise StdinNotImplentedError if active frontend doesn't support\n\u001b[0;32m 687\u001b[0m stdin.\"\"\"\n\u001b[1;32m--> 688\u001b[1;33m raise StdinNotImplementedError(\"raw_input was called, but this \"\n\u001b[0m\u001b[0;32m 689\u001b[0m \"frontend does not support stdin.\") \n\u001b[0;32m 690\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mStdinNotImplementedError\u001b[0m: raw_input was called, but this frontend does not support stdin." + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": "Welcome to the ultimate man-machine showdown: Tic-Tac-Toe.\n--where human brain is pit against silicon processor\nMake your move known by entering a number, 0 - 8. The number\ncorresponds to the desired board position, as illustrated:\n0 | 1 | 2\n---------\n3 | 4 | 5\n\n---------\n6 | 7 | 8\n\n\nPrepare yourself, human. The battle is about to begin.\nDo you require the first move? (y/n): " + } + ], + "prompt_number": 5 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "", + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Beginning_C++_through_game_programming/ch7.ipynb b/Beginning_C++_through_game_programming/ch7.ipynb new file mode 100755 index 00000000..ce1452b8 --- /dev/null +++ b/Beginning_C++_through_game_programming/ch7.ipynb @@ -0,0 +1,112 @@ +{ + "metadata": { + "name": "ch7" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": "Chapter 7 : Pointers: Tic-Tac-Toe 2.0" + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 7.1 page no :225" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\nPointing\nDemonstrates using pointers\nNOte : pointer concept is not in python, so output would be differ.\n'''\n\npScore = 0 #declare and initialize a pointer\nscore = 1000 #assign pointer pScore address of variable score\npScore = score; \nprint \"Assigning &score to pScore\\n\";\nprint \"&score is: \" , id(score) # address of score variable\nprint \"pScore is: \" , pScore # address stored in pointer\nprint \"score is: \" , score\nprint \"pScore is: \" , pScore # value pointed to by pointer\nprint \"Adding 500 to score\";\nscore += 500;\nprint \"score is: \" , score \nprint \"*pScore is: \" , pScore \nprint \"Adding 500 to *pScore\\n\";\npScore += 500;\nprint \"score is: \" , score \nprint \"*pScore is: \" , pScore\nprint \"Assigning &newScore to pScore\\n\";\nnewScore = 5000;\npScore = newScore;\nprint \"&newScore is: \" , id(newScore)\nprint \"pScore is: \" , pScore\nprint \"newScore is: \" , newScore\nprint \"*pScore is: \" , pScore\n\nprint \"Assigning &str to pStr\\n\";\nstr = \"score\";\npStr = str; \nprint \"str is: \" , str\nprint \"*pStr is: \" , pStr\nprint \"(*pStr).size() is: \" , len(pStr)\nprint \"pStr->size() is: \" , len(pStr)", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Assigning &score to pScore\n\n&score is: 24878128\npScore is: 1000\nscore is: 1000\npScore is: 1000\nAdding 500 to score\nscore is: 1500\n*pScore is: 1000\nAdding 500 to *pScore\n\nscore is: 1500\n*pScore is: 1500\nAssigning &newScore to pScore\n\n&newScore is: 24880648\npScore is: 5000\nnewScore is: 5000\n*pScore is: 5000\nAssigning &str to pStr\n\nstr is: score\n*pStr is: score\n(*pStr).size() is: 5\npStr->size() is: 5\n" + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 7.2 page no : 235" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\n// Swap Pointer\n// Demonstrates passing constant pointers to alter argument variables\n'''\n\ndef badSwap(x,y):\n x,y = y,x\n \ndef goodSwap(x,y):\n x[0],y[0] = y[0],x[0]\n\n\nmyScore = [150]\nyourScore = [1000]\nprint \"Original values\";\nprint \"myScore: \" , myScore[0]\nprint \"yourScore: \" , yourScore[0]\nprint \"Calling badSwap()\";\nbadSwap(myScore[0], yourScore[0]);\nprint \"myScore: \" , myScore[0] \nprint \"yourScore: \" , yourScore[0]\nprint \"Calling goodSwap()\\n\";\ngoodSwap(myScore,yourScore);\nprint \"myScore: \" , myScore[0] \nprint \"yourScore: \" , yourScore[0]", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Original values\nmyScore: 150\nyourScore: 1000\nCalling badSwap()\nmyScore: 150\nyourScore: 1000\nCalling goodSwap()\n\nmyScore: 1000\nyourScore: 150\n" + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example : 7.3 page no : 239" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\nInventory Pointer\nDemonstrates returning a pointer\n'''\ndef ptrToElement(pVec, i):\n return pVec[i]\n\ninventory = []\ninventory.append(\"sword\");\ninventory.append(\"armor\");\ninventory.append(\"shield\");\n#displays string object that the returned pointer points to\nprint \"Sending the objected pointed to by returned pointer:\";\nprint ptrToElement(inventory, 0)\n# assigns one pointer to another - - inexpensive assignment\nprint \"Assigning the returned pointer to another pointer.\";\npStr = ptrToElement(inventory, 1);\nprint \"Sending the object pointed to by new pointer to cout:\";\nprint pStr \n#copies a string object - - expensive assignment\nprint \"Assigning object pointed by pointer to a string object.\\n\";\ns = (ptrToElement(inventory, 2));\nprint \"Sending the new string object to cout:\";\nprint s \n#altering the string object through a returned pointer\nprint \"Altering an object through a returned pointer.\";\npStr = \"Healing Potion\";\ninventory[1] = pStr\nprint \"Sending the altered object to cout:\\n\";\nprint inventory[1] ", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Sending the objected pointed to by returned pointer:\nsword\nAssigning the returned pointer to another pointer.\nSending the object pointed to by new pointer to cout:\narmor\nAssigning object pointed by pointer to a string object.\n\nSending the new string object to cout:\nshield\nAltering an object through a returned pointer.\nSending the altered object to cout:\n\nHealing Potion\n" + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": "example 7.4 page no : 244" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "'''\n//Array Passer\n//Demonstrates relationship between pointers and arrays\n'''\ndef increase(array,NUM_ELEMENTS):\n for i in range(NUM_ELEMENTS):\n array[i] += 500;\n\ndef display( array, NUM_ELEMENTS):\n for i in range(NUM_ELEMENTS):\n print array[i]\n\n\nprint \"Creating an array of high scores.\\n\\n\";\nNUM_SCORES = 3;\nhighScores = [5000, 3500, 2700]\nprint \"Displaying scores using array name as a constant pointer.\";\nprint highScores[0]\nprint highScores[1]\nprint highScores[2]\nprint \"Increasing scores by passing array as a constant pointer.\";\nincrease(highScores, NUM_SCORES)\nprint \"Displaying scores by passing array as a constant pointer to a constant.\";\ndisplay(highScores, NUM_SCORES);", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Creating an array of high scores.\n\n\nDisplaying scores using array name as a constant pointer.\n5000\n3500\n2700\nIncreasing scores by passing array as a constant pointer.\nDisplaying scores by passing array as a constant pointer to a constant.\n5500\n4000\n3200\n" + } + ], + "prompt_number": 4 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "", + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Beginning_C++_through_game_programming/ch8.ipynb b/Beginning_C++_through_game_programming/ch8.ipynb new file mode 100755 index 00000000..1b140b06 --- /dev/null +++ b/Beginning_C++_through_game_programming/ch8.ipynb @@ -0,0 +1,484 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8 : Classes: Critter Caretaker" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 8.1 page no : 256" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "Simple Critter\n", + "Demonstrates creating a new type\n", + "'''\n", + "\n", + "class Critter:\n", + " def __init__(self):\n", + " self.m_Hunger = 0\n", + "\n", + " def Greet(self):\n", + " print \"Hi. I'm a critter. My hunger level is \" , self.m_Hunger\n", + "\n", + "crit1 = Critter()\n", + "crit2 = Critter()\n", + "crit1.m_Hunger = 9;\n", + "print \"crit1's hunger level is \" , crit1.m_Hunger\n", + "crit2.m_Hunger = 3;\n", + "print \"crit2's hunger level is \" , crit2.m_Hunger\n", + "crit1.Greet()\n", + "crit2.Greet()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "crit1's hunger level is 9\n", + "crit2's hunger level is 3\n", + "Hi. I'm a critter. My hunger level is 9\n", + "Hi. I'm a critter. My hunger level is 3\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 8.2 page no: 261" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "Constructor Critter\n", + "Demonstrates constructors\n", + "'''\n", + "\n", + "class Critter:\n", + " def __init__(self,h=0):\n", + " print \"A new critter has been born!\" \n", + " self.m_Hunger = h\n", + "\n", + " def Greet(self):\n", + " print \"Hi. I'm a critter. My hunger level is \" , self.m_Hunger\n", + "\n", + "crit = Critter(7);\n", + "crit.Greet();" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "A new critter has been born!\n", + "Hi. I'm a critter. My hunger level is 7\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 8.3 page no : 265" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "Private Critter\n", + "Demonstrates setting member access levels\n", + "'''\n", + "\n", + "class Critter:\n", + " def __init__(self,h=0):\n", + " print \"A new critter has been born!\" \n", + " self.m_Hunger = h\n", + "\n", + " def Greet(self):\n", + " print \"Hi. I'm a critter. My hunger level is \" , self.m_Hunger\n", + "\n", + " def GetHunger(self):\n", + " return self.m_Hunger;\n", + "\n", + " def SetHunger(self,hunger):\n", + " if (hunger < 0):\n", + " print \"You can't set a critter's hunger to a negative number.\";\n", + " else:\n", + " self.m_Hunger = hunger;\n", + "\n", + "\n", + "crit = Critter(5)\n", + "#print crit.m_Hunger; //illegal, m_Hunger is private!\n", + "print \"Calling GetHunger(): \" , crit.GetHunger()\n", + "print \"Calling SetHunger() with -1.\";\n", + "crit.SetHunger(-1);\n", + "print \"Calling SetHunger() with 9.\";\n", + "crit.SetHunger(9);\n", + "print \"Calling GetHunger(): \" , crit.GetHunger()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "A new critter has been born!\n", + "Calling GetHunger(): 5\n", + "Calling SetHunger() with -1.\n", + "You can't set a critter's hunger to a negative number.\n", + "Calling SetHunger() with 9.\n", + "Calling GetHunger(): 9\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 8.4 page no: 270" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "//Static Critter\n", + "//Demonstrates static member variables and functions\n", + "'''\n", + "\n", + "class Critter:\n", + " s_Total = 0\n", + " def __init__(self,h=0):\n", + " print \"A new critter has been born!\" \n", + " self.m_Hunger = h\n", + " Critter.s_Total += 1\n", + "\n", + " def GetTotal(self):\n", + " return Critter.s_Total;\n", + "\n", + "print \"The total number of critters is: \";\n", + "print Critter.s_Total\n", + "crit1 = Critter() \n", + "crit2 = Critter()\n", + "crit3 = Critter()\n", + "print \"\\nThe total number of critters is: \",\n", + "print Critter.GetTotal(crit1) " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The total number of critters is: \n", + "0\n", + "A new critter has been born!\n", + "A new critter has been born!\n", + "A new critter has been born!\n", + "\n", + "The total number of critters is: 3\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 8.5 page no : 277" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "//Critter Caretaker\n", + "//Simulates caring for a virtual pet\n", + "Note : Book program has error, PassTime() is taking time integer as argument, but while calling it , no-function is \n", + "passing that time so this would give error.\n", + "'''\n", + "\n", + "\n", + "class Critter:\n", + " def __init__(self,hunger = 0, boredom = 0):\n", + " self.m_Hunger= hunger\n", + " self.m_Boredom = boredom\n", + "\n", + " def GetMood(self):\n", + " return (self.m_Hunger + self.m_Boredom);\n", + "\n", + " def PassTime(self,time):\n", + " self.m_Hunger += time;\n", + " self.m_Boredom += time;\n", + "\n", + " def Talk(self):\n", + " print \"I'm a critter and I feel \";\n", + " mood = self.GetMood();\n", + " if (mood > 15):\n", + " print \"mad.\\n\";\n", + " elif (mood > 10):\n", + " print \"frustrated.\\n\";\n", + " elif (mood > 5):\n", + " print \"okay.\\n\";\n", + " else:\n", + " print \"happy.\\n\";\n", + " self.PassTime();\n", + "\n", + " def Eat(self,food):\n", + " print \"Brruppp.\\n\";\n", + " self.m_Hunger -= food;\n", + " if (self.m_Hunger < 0):\n", + " self.m_Hunger = 0;\n", + " self.PassTime();\n", + "\n", + " def Play(self,fun):\n", + " print \"Wheee!\\n\";\n", + " self.m_Boredom -= fun;\n", + " if (self.m_Boredom < 0):\n", + " self.m_Boredom = 0;\n", + " self.PassTime();\n", + "\n", + "crit = Critter()\n", + "crit.Talk();\n", + "while True:\n", + " print \"\\nCritter Caretaker\\n\\n\";\n", + " print \"0 - Quit\\n\";\n", + " print \"1 - Listen to your critter\\n\";\n", + " print \"2 - Feed your critter\\n\";\n", + " print \"3 - Play with your critter\\n\\n\";\n", + " print \"Choice: \";\n", + " choice = int(raw_input())\n", + " if choice == 0:\n", + " print \"Good-bye.\\n\";\n", + " break\n", + " elif choice == 1:\n", + " crit.Talk();\n", + " elif choice == 2:\n", + " crit.Eat();\n", + " elif choice == 3:\n", + " crit.Play();\n", + " else:\n", + " print \"\\nSorry, but \" , choice , \" isn't a valid choice.\\n\";\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "PassTime() takes exactly 2 arguments (1 given)", + "output_type": "pyerr", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m<ipython-input-1-6005a1e33d51>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 47\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 48\u001b[0m \u001b[0mcrit\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mCritter\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 49\u001b[1;33m \u001b[0mcrit\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mTalk\u001b[0m\u001b[1;33m(\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 50\u001b[0m \u001b[1;32mwhile\u001b[0m \u001b[0mTrue\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 51\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"\\nCritter Caretaker\\n\\n\"\u001b[0m\u001b[1;33m;\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m<ipython-input-1-6005a1e33d51>\u001b[0m in \u001b[0;36mTalk\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 30\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 31\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"happy.\\n\"\u001b[0m\u001b[1;33m;\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 32\u001b[1;33m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mPassTime\u001b[0m\u001b[1;33m(\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 33\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 34\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mEat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mfood\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mTypeError\u001b[0m: PassTime() takes exactly 2 arguments (1 given)" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "I'm a critter and I feel \n", + "happy.\n", + "\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 8.6 page no : 280" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "Critter Caretaker\n", + "Simulates caring for a virtual pet\n", + "'''\n", + "\n", + "\n", + "class Critter:\n", + " def __init__(self,hunger = 0, boredom = 0):\n", + " self.m_Hunger= hunger\n", + " self.m_Boredom = boredom\n", + "\n", + " def Talk(self):\n", + " print \"I'm a critter and I feel \";\n", + " mood = self.GetMood();\n", + " if (mood > 15):\n", + " print \"mad.\\n\";\n", + " elif (mood > 10):\n", + " print \"frustrated.\\n\";\n", + " elif (mood > 5):\n", + " print \"okay.\\n\";\n", + " else:\n", + " print \"happy.\\n\";\n", + " self.PassTime();\n", + " \n", + " def Eat(self,food = 4):\n", + " print \"Brruppp.\";\n", + " self.m_Hunger -= food;\n", + " if (self.m_Hunger < 0):\n", + " self.m_Hunger = 0;\n", + " self.PassTime();\n", + " \n", + " def Play(self,fun = 4):\n", + " print \"Wheee!\";\n", + " self.m_Boredom -= fun;\n", + " if (self.m_Boredom < 0):\n", + " self.m_Boredom = 0;\n", + " self.PassTime();\n", + " \n", + " def PassTime(self, time = 1):\n", + " self.m_Hunger += time;\n", + " self.m_Boredom += time;\n", + "\n", + "\n", + " def GetMood(self):\n", + " return (self.m_Hunger + self.m_Boredom);\n", + "\n", + "crit = Critter()\n", + "crit.Talk();\n", + "choice = 1;\n", + "choices = [1,2,3,0]\n", + "i = 0\n", + "while choice != 0 :\n", + " print \"\\nCritter Caretaker\\n\";\n", + " print \"0 - Quit\";\n", + " print \"1 - Listen to your critter\";\n", + " print \"2 - Feed your critter\";\n", + " print \"3 - Play with your critter\\n\";\n", + "\n", + " print \"Choice: \",\n", + " choice = choices[i] #int(raw_input())\n", + " i += 1\n", + "\n", + " if choice ==0:\n", + " print \"Good-bye.\\n\";\n", + " elif choice==1:\n", + " crit.Talk(); \n", + " elif choice == 2:\n", + " crit.Eat();\n", + " elif choice == 3:\n", + " crit.Play();\n", + " else:\n", + " print \"\\nSorry, but \" , choice , \" isn't a valid choice.\";" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " I'm a critter and I feel \n", + "happy.\n", + "\n", + "\n", + "Critter Caretaker\n", + "\n", + "0 - Quit\n", + "1 - Listen to your critter\n", + "2 - Feed your critter\n", + "3 - Play with your critter\n", + "\n", + "Choice: I'm a critter and I feel \n", + "happy.\n", + "\n", + "\n", + "Critter Caretaker\n", + "\n", + "0 - Quit\n", + "1 - Listen to your critter\n", + "2 - Feed your critter\n", + "3 - Play with your critter\n", + "\n", + "Choice: Brruppp.\n", + "\n", + "Critter Caretaker\n", + "\n", + "0 - Quit\n", + "1 - Listen to your critter\n", + "2 - Feed your critter\n", + "3 - Play with your critter\n", + "\n", + "Choice: Wheee!\n", + "\n", + "Critter Caretaker\n", + "\n", + "0 - Quit\n", + "1 - Listen to your critter\n", + "2 - Feed your critter\n", + "3 - Play with your critter\n", + "\n", + "Choice: Good-bye.\n", + "\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Beginning_C++_through_game_programming/ch9.ipynb b/Beginning_C++_through_game_programming/ch9.ipynb new file mode 100755 index 00000000..4c67034d --- /dev/null +++ b/Beginning_C++_through_game_programming/ch9.ipynb @@ -0,0 +1,469 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 9 : Advanced Classes and Dynamic Memory: Game Lobby" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 9.1 page no : 288" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "//Critter Farm\n", + "//Demonstrates object containment\n", + "'''\n", + "class Critter:\n", + " def __init__(self,name=\"\"):\n", + " self.m_Name = name\n", + "\n", + " def GetName(self):\n", + " return self.m_Name;\n", + "\n", + "class Farm:\n", + " def __init__(self,spaces = 1):\n", + " self.m_Critters = []\n", + "\n", + " def Add(self,aCritter):\n", + " self.m_Critters.append(aCritter);\n", + "\n", + " def RollCall(self):\n", + " for i in self.m_Critters:\n", + " print i.GetName() , \" here.\";\n", + "\n", + "crit = Critter(\"Poochie\");\n", + "print \"My critter's name is \" , crit.GetName()\n", + "print \"\\nCreating critter farm.\";\n", + "myFarm = Farm(3)\n", + "print \"Adding three critters to the farm.\";\n", + "myFarm.Add(Critter(\"Moe\"));\n", + "myFarm.Add(Critter(\"Larry\"));\n", + "myFarm.Add(Critter(\"Curly\"));\n", + "print \"Calling Roll. . .\";\n", + "myFarm.RollCall();" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "My critter's name is Poochie\n", + "\n", + "Creating critter farm.\n", + "Adding three critters to the farm.\n", + "Calling Roll. . .\n", + "Moe here.\n", + "Larry here.\n", + "Curly here.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 9.2 page no : 293" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "//Friend Critter\n", + "//Demonstrates friend functions and operator overloading\n", + "'''\n", + "\n", + "class Critter:\n", + " def __init__(self,name=\"\"):\n", + " self.m_Name = name\n", + "\n", + " def GetName(self):\n", + " return self.m_Name;\n", + "\n", + "\n", + "def Peek(aCritter):\n", + " print aCritter.m_Name\n", + "\n", + "def print_(aCritter):\n", + " print \"Critter Object - \",\n", + " print \"m_Name: \" , aCritter.m_Name,\n", + "\n", + "\n", + "crit = Critter(\"Poochie\");\n", + "print \"Calling Peek() to access crit's private data member, m_Name: \";\n", + "Peek(crit);\n", + "print \"Sending crit object to cout with the , operator:\";\n", + "print_(crit)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Calling Peek() to access crit's private data member, m_Name: \n", + "Poochie\n", + "Sending crit object to cout with the , operator:\n", + "Critter Object - m_Name: Poochie\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 9.3 page no : 297" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "// Heap\n", + "// Demonstrates dynamically allocating memory\n", + "'''\n", + "def intOnHeap():\n", + " pTemp = []\n", + " return pTemp;\n", + "\n", + "def leak1():\n", + " drip1 = []\n", + "\n", + "def leak2():\n", + " drip2 = []\n", + "\n", + "\n", + "pHeap = 10;\n", + "print \"*pHeap: \" , pHeap\n", + "pHeap2 = intOnHeap();\n", + "print \"pHeap2: \" , pHeap2 \n", + "print \"Freeing memory pointed to by pHeap.\"; # python automatically deletes the memory.\n", + "print \"Freeing memory pointed to by pHeap2.\";\n", + "pHeap = 0;\n", + "pHeap2 = 0;" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "*pHeap: 10\n", + "pHeap2: []\n", + "Freeing memory pointed to by pHeap.\n", + "Freeing memory pointed to by pHeap2.\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 9.4 page no : 304" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "//Heap Data Member\n", + "//Demonstrates an object with a dynamically allocated data member\n", + "'''\n", + "\n", + "\n", + "class Critter:\n", + " def __init__(self,name=None,age=None):\n", + " if (age!=None and name != None) or (age==None and name==None):\n", + " print \"Constructor called\";\n", + " self.m_pName = name\n", + " self.m_Age = age\n", + " else:\n", + " print \"Copy Constructor called\";\n", + " self.m_pName = name.m_pName\n", + " self.m_Age = name.m_Age;\n", + "\n", + " def GetName(self):\n", + " return self.m_Name;\n", + "\n", + " def __del__(self):\n", + " print \"Destructor called\\n\";\n", + "\n", + " def operator(self,c):\n", + " print \"Overloaded Assignment Operator called\";\n", + " return self\n", + " \n", + " def Greet(self):\n", + " print \"I'm \" , self.m_pName , \" and I'm \" , self.m_Age , \" years old.\";\n", + " print \"&m_pName: \" , \n", + " print id(self.m_pName)\n", + "\n", + "\n", + "def testDestructor():\n", + " toDestroy = Critter(\"Rover\", 3);\n", + " toDestroy.Greet(); \n", + "\n", + "def testCopyConstructor(aCopy):\n", + " aCopy.Greet();\n", + "\n", + "def testAssignmentOp():\n", + " crit1 = Critter(\"crit1\", 7);\n", + " crit2 = Critter(\"crit2\", 9);\n", + " crit1 = crit2;\n", + " crit1.Greet();\n", + " crit2.Greet();\n", + " crit3 = Critter(\"crit\", 11);\n", + " crit3 = crit3;\n", + " crit3.Greet();\n", + "\n", + "testDestructor();\n", + "print ''\n", + "crit = Critter(\"Poochie\", 5);\n", + "crit.Greet();\n", + "testCopyConstructor(crit);\n", + "crit.Greet();\n", + "print ''\n", + "testAssignmentOp();" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor called\n", + "I'm Rover and I'm 3 years old.\n", + "&m_pName: 30745776\n", + "Destructor called\n", + "\n", + "\n", + "Constructor called\n", + "I'm Poochie and I'm 5 years old.\n", + "&m_pName: 30744672\n", + "I'm Poochie and I'm 5 years old.\n", + "&m_pName: 30744672\n", + "I'm Poochie and I'm 5 years old.\n", + "&m_pName: 30744672\n", + "\n", + "Constructor called\n", + "Constructor called\n", + "Destructor called\n", + "\n", + "I'm crit2 and I'm 9 years old.\n", + "&m_pName: 30725152\n", + "I'm crit2 and I'm 9 years old.\n", + "&m_pName: 30725152\n", + "Constructor called\n", + "I'm crit and I'm 11 years old.\n", + "&m_pName: 30744624\n", + "Destructor called\n", + "\n", + "Destructor called\n", + "\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "example 9.5 and 9.6 page no : 318" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "'''\n", + "defining player and lobby classes\n", + "'''\n", + "\n", + "class Player:\n", + " def __init__(self,name):\n", + " self.m_Name =name\n", + " self.m_pNext = 0\n", + "\n", + " def GetName(self):\n", + " return self.m_Name;\n", + "\n", + " def GetNext(self):\n", + " return self.m_pNext;\n", + "\n", + " def SetNext(self,next):\n", + " self.m_pNext = next;\n", + " \n", + "class Lobby:\n", + " def __init__(self):\n", + " self.m_pHead =0\n", + "\n", + " def __del__(self):\n", + " self.Clear();\n", + "\n", + " def AddPlayer(self):\n", + " #create a new player node\n", + " print \"Please enter the name of the new player: \",\n", + " name = 'abc' #raw_input()\n", + " pNewPlayer = Player(name);\n", + " #if list is empty, make head of list this new player\n", + " if (self.m_pHead == 0):\n", + " self.m_pHead = pNewPlayer;\n", + " #otherwise find the end of the list and add the player there\n", + " else:\n", + " pIter = self.m_pHead;\n", + " while (pIter.GetNext() != 0):\n", + " pIter = pIter.GetNext();\n", + " pIter.SetNext(pNewPlayer);\n", + " \n", + " def RemovePlayer(self):\n", + " if (self.m_pHead == 0):\n", + " print \"The game lobby is empty.\"\n", + " else:\n", + " pTemp = self.m_pHead;\n", + " self.m_pHead = self.m_pHead.GetNext();\n", + "\n", + " def Clear(self):\n", + " while (self.m_pHead != 0):\n", + " RemovePlayer();\n", + "\n", + " def print_(self):\n", + " pIter = self.m_pHead;\n", + "\n", + " print \"Here's who's in the game lobby:\";\n", + " if (pIter == 0):\n", + " print \"The lobby is empty.\\n\";\n", + " else:\n", + " while (pIter != 0):\n", + " print pIter.GetName()\n", + " pIter = pIter.GetNext();\n", + "\n", + "myLobby = Lobby()\n", + "choice = 1 \n", + "choices = [1,2,3,0]\n", + "i = 0\n", + "while (choice != 0):\n", + " print myLobby.print_();\n", + " print \"\\nGAME LOBBY\";\n", + " print \"0 - Exit the program.\";\n", + " print \"1 - Add a player to the lobby.\";\n", + " print \"2 - Remove a player from the lobby.\";\n", + " print \"3 - Clear the lobby.\";\n", + " print \"\\nEnter choice: \",\n", + " choice = choices[i] #int(raw_input())\n", + " i += 1\n", + " if choice ==0:\n", + " print \"Good-bye.\"\n", + " elif choice ==1: \n", + " myLobby.AddPlayer()\n", + " elif choice==2: \n", + " myLobby.RemovePlayer(); \n", + " elif choice==3: \n", + " myLobby.Clear()\n", + " else:\n", + " print \"That was not a valid choice.\\n\";" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Here's who's in the game lobby:\n", + "The lobby is empty.\n", + "\n", + "None\n", + "\n", + "GAME LOBBY\n", + "0 - Exit the program.\n", + "1 - Add a player to the lobby.\n", + "2 - Remove a player from the lobby.\n", + "3 - Clear the lobby.\n", + "\n", + "Enter choice: Please enter the name of the new player: Here's who's in the game lobby:\n", + "abc\n", + "None\n", + "\n", + "GAME LOBBY\n", + "0 - Exit the program.\n", + "1 - Add a player to the lobby.\n", + "2 - Remove a player from the lobby.\n", + "3 - Clear the lobby.\n", + "\n", + "Enter choice: Here's who's in the game lobby:\n", + "The lobby is empty.\n", + "\n", + "None\n", + "\n", + "GAME LOBBY\n", + "0 - Exit the program.\n", + "1 - Add a player to the lobby.\n", + "2 - Remove a player from the lobby.\n", + "3 - Clear the lobby.\n", + "\n", + "Enter choice: Here's who's in the game lobby:\n", + "The lobby is empty.\n", + "\n", + "None\n", + "\n", + "GAME LOBBY\n", + "0 - Exit the program.\n", + "1 - Add a player to the lobby.\n", + "2 - Remove a player from the lobby.\n", + "3 - Clear the lobby.\n", + "\n", + "Enter choice: Good-bye.\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Beginning_C++_through_game_programming/screenshots/chapter1.png b/Beginning_C++_through_game_programming/screenshots/chapter1.png Binary files differnew file mode 100755 index 00000000..44527cdd --- /dev/null +++ b/Beginning_C++_through_game_programming/screenshots/chapter1.png diff --git a/Beginning_C++_through_game_programming/screenshots/chapter4.png b/Beginning_C++_through_game_programming/screenshots/chapter4.png Binary files differnew file mode 100755 index 00000000..eb1b6ea5 --- /dev/null +++ b/Beginning_C++_through_game_programming/screenshots/chapter4.png diff --git a/Beginning_C++_through_game_programming/screenshots/chapter8.png b/Beginning_C++_through_game_programming/screenshots/chapter8.png Binary files differnew file mode 100755 index 00000000..1032e338 --- /dev/null +++ b/Beginning_C++_through_game_programming/screenshots/chapter8.png diff --git a/C++_from_the_Ground/Chapter_10.ipynb b/C++_from_the_Ground/Chapter_10.ipynb index b19c3a4c..b19c3a4c 100644..100755 --- a/C++_from_the_Ground/Chapter_10.ipynb +++ b/C++_from_the_Ground/Chapter_10.ipynb diff --git a/C++_from_the_Ground/Chapter_11.ipynb b/C++_from_the_Ground/Chapter_11.ipynb index fdd70bcf..fdd70bcf 100644..100755 --- a/C++_from_the_Ground/Chapter_11.ipynb +++ b/C++_from_the_Ground/Chapter_11.ipynb diff --git a/C++_from_the_Ground/Chapter_12.ipynb b/C++_from_the_Ground/Chapter_12.ipynb index a29c9b4d..a29c9b4d 100644..100755 --- a/C++_from_the_Ground/Chapter_12.ipynb +++ b/C++_from_the_Ground/Chapter_12.ipynb diff --git a/C++_from_the_Ground/Chapter_13.ipynb b/C++_from_the_Ground/Chapter_13.ipynb index 6d12a5a7..6d12a5a7 100644..100755 --- a/C++_from_the_Ground/Chapter_13.ipynb +++ b/C++_from_the_Ground/Chapter_13.ipynb diff --git a/C++_from_the_Ground/Chapter_14.ipynb b/C++_from_the_Ground/Chapter_14.ipynb index 2f8447ba..2f8447ba 100644..100755 --- a/C++_from_the_Ground/Chapter_14.ipynb +++ b/C++_from_the_Ground/Chapter_14.ipynb diff --git a/C++_from_the_Ground/Chapter_15.ipynb b/C++_from_the_Ground/Chapter_15.ipynb index 211b1c7d..211b1c7d 100644..100755 --- a/C++_from_the_Ground/Chapter_15.ipynb +++ b/C++_from_the_Ground/Chapter_15.ipynb diff --git a/C++_from_the_Ground/Chapter_16.ipynb b/C++_from_the_Ground/Chapter_16.ipynb index 98e3dc8a..98e3dc8a 100644..100755 --- a/C++_from_the_Ground/Chapter_16.ipynb +++ b/C++_from_the_Ground/Chapter_16.ipynb diff --git a/C++_from_the_Ground/Chapter_17.ipynb b/C++_from_the_Ground/Chapter_17.ipynb index c50f48aa..c50f48aa 100644..100755 --- a/C++_from_the_Ground/Chapter_17.ipynb +++ b/C++_from_the_Ground/Chapter_17.ipynb diff --git a/C++_from_the_Ground/Chapter_18.ipynb b/C++_from_the_Ground/Chapter_18.ipynb index df4cabc2..df4cabc2 100644..100755 --- a/C++_from_the_Ground/Chapter_18.ipynb +++ b/C++_from_the_Ground/Chapter_18.ipynb diff --git a/C++_from_the_Ground/Chapter_19.ipynb b/C++_from_the_Ground/Chapter_19.ipynb index 7f04b7ea..7f04b7ea 100644..100755 --- a/C++_from_the_Ground/Chapter_19.ipynb +++ b/C++_from_the_Ground/Chapter_19.ipynb diff --git a/C++_from_the_Ground/Chapter_2.ipynb b/C++_from_the_Ground/Chapter_2.ipynb index b3976867..b3976867 100644..100755 --- a/C++_from_the_Ground/Chapter_2.ipynb +++ b/C++_from_the_Ground/Chapter_2.ipynb diff --git a/C++_from_the_Ground/Chapter_20.ipynb b/C++_from_the_Ground/Chapter_20.ipynb index 8771c6cd..8771c6cd 100644..100755 --- a/C++_from_the_Ground/Chapter_20.ipynb +++ b/C++_from_the_Ground/Chapter_20.ipynb diff --git a/C++_from_the_Ground/Chapter_21.ipynb b/C++_from_the_Ground/Chapter_21.ipynb index 76345922..76345922 100644..100755 --- a/C++_from_the_Ground/Chapter_21.ipynb +++ b/C++_from_the_Ground/Chapter_21.ipynb diff --git a/C++_from_the_Ground/Chapter_22.ipynb b/C++_from_the_Ground/Chapter_22.ipynb index 39b8cb88..39b8cb88 100644..100755 --- a/C++_from_the_Ground/Chapter_22.ipynb +++ b/C++_from_the_Ground/Chapter_22.ipynb diff --git a/C++_from_the_Ground/Chapter_3.ipynb b/C++_from_the_Ground/Chapter_3.ipynb index 9d0cf326..9d0cf326 100644..100755 --- a/C++_from_the_Ground/Chapter_3.ipynb +++ b/C++_from_the_Ground/Chapter_3.ipynb diff --git a/C++_from_the_Ground/Chapter_4.ipynb b/C++_from_the_Ground/Chapter_4.ipynb index ca8e76db..ca8e76db 100644..100755 --- a/C++_from_the_Ground/Chapter_4.ipynb +++ b/C++_from_the_Ground/Chapter_4.ipynb diff --git a/C++_from_the_Ground/Chapter_5.ipynb b/C++_from_the_Ground/Chapter_5.ipynb index 13085f5e..13085f5e 100644..100755 --- a/C++_from_the_Ground/Chapter_5.ipynb +++ b/C++_from_the_Ground/Chapter_5.ipynb diff --git a/C++_from_the_Ground/Chapter_6.ipynb b/C++_from_the_Ground/Chapter_6.ipynb index 5010922a..5010922a 100644..100755 --- a/C++_from_the_Ground/Chapter_6.ipynb +++ b/C++_from_the_Ground/Chapter_6.ipynb diff --git a/C++_from_the_Ground/Chapter_7.ipynb b/C++_from_the_Ground/Chapter_7.ipynb index 027b30f5..027b30f5 100644..100755 --- a/C++_from_the_Ground/Chapter_7.ipynb +++ b/C++_from_the_Ground/Chapter_7.ipynb diff --git a/C++_from_the_Ground/Chapter_8.ipynb b/C++_from_the_Ground/Chapter_8.ipynb index 4684861e..4684861e 100644..100755 --- a/C++_from_the_Ground/Chapter_8.ipynb +++ b/C++_from_the_Ground/Chapter_8.ipynb diff --git a/C++_from_the_Ground/Chapter_9.ipynb b/C++_from_the_Ground/Chapter_9.ipynb index 0f30e9a8..0f30e9a8 100644..100755 --- a/C++_from_the_Ground/Chapter_9.ipynb +++ b/C++_from_the_Ground/Chapter_9.ipynb diff --git a/Mechanics_Of_Fluids/README.txt b/Mechanics_Of_Fluids/README.txt new file mode 100755 index 00000000..028e7b12 --- /dev/null +++ b/Mechanics_Of_Fluids/README.txt @@ -0,0 +1,10 @@ +Contributed By: Jatin Pavagadhi +Course: mca +College/Institute/Organization: C-DEC , Pune +Department/Designation: Developer +Book Title: Mechanics Of Fluids +Author: A. C. Walshaw And D. A. Jobson +Publisher: Longmans, London +Year of publication: 1962 +Isbn: 0072472103 +Edition: 1
\ No newline at end of file diff --git a/Mechanics_Of_Fluids/ch1.ipynb b/Mechanics_Of_Fluids/ch1.ipynb new file mode 100755 index 00000000..37f784f3 --- /dev/null +++ b/Mechanics_Of_Fluids/ch1.ipynb @@ -0,0 +1,403 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1 : Buoyancy and Stability" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.4.1 Page no : 5" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "#initialisation of variables\n", + "ws= 64. \t\t\t#lbf/ft**3\n", + "wi= 57. \t\t\t#lbf/ft**3\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "vabyvb= (ws/wi)-1\n", + "vtbyva= (1./vabyvb)+1\n", + "vabyvt= (1./vtbyva)*100\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'percentage of total volume extended above the surface= %.1f per cent'%(vabyvt)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "percentage of total volume extended above the surface= 10.9 per cent\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.4.2 page no :5" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "p= 20. \t\t\t#lbf/in**2\n", + "d1= 4. \t\t\t#in\n", + "d2= 18. \t\t\t#in\n", + "d3= 0.5 \t\t\t#in\n", + "sw= 62.3 \t\t\t#lbf/ft**3\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Fa= p*(math.pi/4)*d3**2\n", + "Fb= (4/d2)*3.92\n", + "V= 1.5*(Fb/sw)*1728\n", + "r= (0.75*(V/math.pi))**(1/3.)\n", + "d= 2*r\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'diameter of the float= %.2f in'%(d)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "diameter of the float= 4.11 in\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.6.1 page no : 12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \t\t\t\n", + "\n", + "#initialisation of variables\n", + "delta_W= 4. \t\t\t#tonf\n", + "x= 30. \t\t\t#ft\n", + "W= 2000. \t\t\t#tonf\n", + "O1=(0.015)\n", + "O2= -0.015\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "O = O1-O2\n", + "GM = (delta_W*x)/(W*O)\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'metacentric height= %.f ft'%(GM)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "metacentric height= 2 ft\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.6.2 page no : 12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + " \n", + "#initialisation of variables\n", + "ws= 1./35 \t\t\t#tonf/ft**3\n", + "A= 10500. \t\t\t#ft**2\n", + "wf= 1/36. \t\t\t#tonf/ft**3\n", + "Wo= 7000. \t\t\t#tonf\n", + "Wf= 6950.\t\t\t#tonf\n", + "li= 300. \t\t\t#ft\n", + "lh= 400. \t\t\t#ft\n", + "l= 7200. \t\t\t#ft\n", + "l1=50. \t\t\t #ft\n", + "l2= 10. \t\t\t#ft\n", + "l3= 250. \t\t\t#ft\n", + "l4= 40. \t\t\t#ft\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Dod= (1./A)*((Wo/wf)-(Wf/ws)) #decrease of draught(ft)\n", + "Ac= ws*A*Dod #additional cargo(tonf)\n", + "x= (l1*l2+l3*l4)/(l+l3-l1*l2)\n", + "do= (x/lh)*li\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'change of draught= %.3f ft'%(Dod)\n", + "print ' Additional cargo=%.f tonf'%(Ac)\n", + "print ' change of trim=%.1f ft'%(do) \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "change of draught= 0.833 ft\n", + " Additional cargo=250 tonf\n", + " change of trim=1.1 ft\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.6.3 page no : 14\n" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "M= 500. \t\t\t#tonf ft/in\n", + "D= 32. \t\t\t #tonf/in\n", + "l= 200. \t\t\t#ft\n", + "L= 380. \t\t\t#ft\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "x= l+(M/D)*(L/l)\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'length= %.1f ft aft'%(x)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "length= 229.7 ft aft\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.7.2 page no : 19" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "a= 6.\n", + "b= -6.\n", + "c= 1.\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "s1= (-b+math.sqrt(b**2-4*a*c))/(2*a)\n", + "s2= (-b-math.sqrt(b**2-4*a*c))/(2*a)\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'upper limit for specific gravity s= %.3f '%(s1)\n", + "print 'lower limit for specific gravity s=%.3f tonf'%(s2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "upper limit for specific gravity s= 0.789 \n", + "lower limit for specific gravity s=0.211 tonf\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.7.3 page no : 21" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "b= 350. \t\t\t#ft\n", + "d= 12. \t\t\t#ft\n", + "L= 46. \t\t\t#ft\n", + "Ac1= 500.*80*12 \t\t\t#ft**3\n", + "Ac2= 350.*12*9 \t\t\t#ft**3\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Ic= (b*d**3)/12.\n", + "A= b*d\n", + "Io= Ic+A*L**2.\n", + "I= 2*Io\n", + "V= Ac1+2*Ac2\n", + "BM= I/V\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'print lacement of body= %.1f ft'%(BM)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "print lacement of body= 32.2 ft\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.8.1 page no : 23" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "W= 4500. \t\t#tonf\n", + "b= 20. \t\t\t#length(ft)\n", + "d= 8. \t\t\t#breadth(ft)\n", + "s= 0.83 #specific gravity\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "I= int(b*d**3/12.)\n", + "r= 3*s*I/(36*W)\n", + "inc = r * 12 # inch\n", + "\n", + "#RESULTS\n", + "print 'Reduction caused by three compartments= %.3f in.'%(inc)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reduction caused by three compartments= 0.157 in.\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.9.1 page no : 25" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "import math \n", + "Kg= 12. \t\t\t#ft\n", + "g= 32.2 \t\t\t#ft/s**2\n", + "GM= 2. \t\t\t#ft\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "T= 2.*math.pi*math.sqrt(Kg**2/(g*GM))\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'periodic time of rolling of the ship= %.1f sec'%(T)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "periodic time of rolling of the ship= 9.4 sec\n" + ] + } + ], + "prompt_number": 10 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Mechanics_Of_Fluids/ch10.ipynb b/Mechanics_Of_Fluids/ch10.ipynb new file mode 100755 index 00000000..c141da0e --- /dev/null +++ b/Mechanics_Of_Fluids/ch10.ipynb @@ -0,0 +1,315 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 10 : Steady Flow in Pipes and Channels" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 10.1.1 page no : 269" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "Q= 450. \t\t\t#ft**3/sec\n", + "k= 0.5\n", + "i= 1./2000\n", + "C= 105. \t\t\t#ft**1/2/sec\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "d= (((Q*math.sqrt(2./i))/(2*math.sqrt(1+k**2-k)*C))**(2./5))*(5.41/7.55)\n", + "b= d/2.\n", + "s= d*math.sqrt(1+k**2.)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' vertical= %.2f ft'%(d)\n", + "print ' horizontal= %.2f ft'%(s)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " vertical= 5.41 ft\n", + " horizontal= 6.05 ft\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 10.2.2 page no : 275" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "\n", + "#initialisation of variables\n", + "\n", + "d= 6. \t\t\t#ft\n", + "C= 95. \t\t\t#ft**0.5/sec\n", + "i= 1./800\n", + "m= 1.705 \t\t\t#ft\n", + "a= 15.16\n", + "g= 32.2 \t\t\t#ft**2/sec\n", + "alpha = 15.30 # degree\t\t\t\n", + "\n", + "#CALCULATIONS\n", + "theta = int(180 + 2*alpha)\n", + "A= ((d/2)**2./2)*(((theta*math.pi)/180)+math.sin(math.radians(2*a)))\n", + "u= C*math.sqrt(m*i)\n", + "Q= A*u\n", + "f= (2*g)/C**2.\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' rate of volumetric flow= %.1f ft**3/sec'%(Q)\n", + "print ' resistance factor= %.5f '%(f)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " rate of volumetric flow= 82.3 ft**3/sec\n", + " resistance factor= 0.00714 \n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 10.3.1 page no : 277" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "\n", + "m= 6. \t\t\t#lb/sec\n", + "w= 62.3\t\t\t#lb/ft**3\n", + "s= 0.9\n", + "l= 2500. \t\t\t#ft\n", + "u= 0.115\n", + "r= 8. \t\t\t#ft\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "\n", + "#CALCULATIONS\n", + "uc = round(2300*u/.25 * 1/(s*w),1)\n", + "v = round(m/(s*w) * 1./(math.pi/4 *1./16),2)\n", + "p1p2 = (r*u)/math.pi * l * 64**2 * 6 /(s*w*g)\n", + "dp= 8.*u*l*r**4*m/(math.pi*s*w*g)\n", + "P= m*dp/(s*w*550.)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Critical Velocity is = %.1f ft/sec'%uc\n", + "print ' Actual Velocity is = %.2f ft/sec'%v\n", + "print ' Power required= %.f h.p'%(P)\n", + "\n", + "# Note : Answers may vary because of rounding error. Please calculate manually." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Critical Velocity is = 18.9 ft/sec\n", + " Actual Velocity is = 2.18 ft/sec\n", + " Power required= 2 h.p\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 10.4.1 page no: 282" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "p= 0.0024 \t\t\t#slug/ft**3\n", + "u= 10. \t\t\t#ft/sec\n", + "v= 3.75*10**-7 \t\t\t#slug\n", + "d= 0.25\t\t\t#in\n", + "u1= 100. \t\t\t#ft/sec\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "R= round(u*d*p/(12.*v),-1)\n", + "f= round(16./R,3)\n", + "F1= f*p*u**2*math.pi*d/(2*12.)\n", + "R1= R*10.\n", + "f1= 0.0791/R1**0.25\n", + "F2= f1*p*u1**2*math.pi*d/(2*12*10.)\n", + "C= F2/F1\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Raynolds number = %.0f'%R\n", + "print ' resistance coefficient = %.2f '%(f)\n", + "print ' Drag force per foot length = %.2e lbf/ft'%(F1)\n", + "print ' Ratio of skin-friction drag forces per ft = %.2f '%(C)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Raynolds number = 1330\n", + " resistance coefficient = 0.01 \n", + " Drag force per foot length = 9.42e-05 lbf/ft\n", + " Ratio of skin-friction drag forces per ft = 6.14 \n" + ] + } + ], + "prompt_number": 22 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 10.4.2 pageno : 283\n" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "\n", + "Q= 0.7\t\t\t#ft**3/sec\n", + "a= 16.\n", + "n= 0.65\n", + "P= 5. \t\t\t#h.p\n", + "l= 3000. \t\t\t#ft\n", + "g= 32.2 \t\t\t#ft**2/sec \n", + "d= 0.85 \t\t\t#gm/cc\n", + "d1= 0.5 \t\t\t#ft\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "u= Q*a/math.pi\n", + "u1= n*P*550.*g/(8*math.pi*u**2*l)\n", + "v= u1/d\n", + "R= round(u*d1*30.5**2/1.05,-1)\n", + "\t\t\t\n", + "#RESULTS\n", + "print \"Coefficient of viscosity is = %.2f ft/sec\"%u\n", + "print ' Reynolds number= %.f '%(R)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Coefficient of viscosity is = 3.57 ft/sec\n", + " Reynolds number= 1580 \n" + ] + } + ], + "prompt_number": 25 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 10.4.3 page no : 285" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \t\t\t\n", + "#initialisation of variables\n", + "\n", + "u1= 80. \t\t\t#ft/sec\n", + "c= 62.\n", + "s= 0.25\n", + "l= 11. \t\t\t#ft\n", + "w= 62.3 \t\t\t#lb/ft**3\n", + "u1= 80. \t\t\t#ft/sec\n", + "d= 2. \t\t\t#lbf/in**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "u= u1*c/(l*w*s)\n", + "P= ((u1/u)**2)*s*d*144./(l*w)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' water velocity = %.2f ft/sec'%(u)\n", + "print ' w pressure drop = %.3f lbf/ft**2 per ft length'%(P)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " water velocity = 28.95 ft/sec\n", + " w pressure drop = 0.802 lbf/ft**2 per ft length\n" + ] + } + ], + "prompt_number": 27 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Mechanics_Of_Fluids/ch11.ipynb b/Mechanics_Of_Fluids/ch11.ipynb new file mode 100755 index 00000000..9b47c624 --- /dev/null +++ b/Mechanics_Of_Fluids/ch11.ipynb @@ -0,0 +1,605 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 11 : Flow and Power Transmission through Pipe-lines" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.2.1 page no : 307" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "Q= 0.5 \t\t\t#ft**3/sec\n", + "d= 3. \t\t\t#in\n", + "d1= 4. \t\t\t#in\n", + "d2= 2. \t\t\t#in\n", + "h= 12.7 \t\t\t#in\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "s= 13.6 \t\t\t#kg/m**3\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "k = (s-1)*(h/2.)*2.*g*(math.pi/(Q*d**2*4))**2.+((d1/d)**4.-1)\n", + "Cc = (d1/d2)**2./(math.sqrt(k)+1.)\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "print ' contraction coefficient= %.3f '%(Cc)\n", + "print ' ANSWER GIVEN IN THE TEXTBOOK IS WRONG'\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " contraction coefficient= 0.294 \n", + " ANSWER GIVEN IN THE TEXTBOOK IS WRONG\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.3.1 page no : 310" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "import math \n", + "#initialisation of variables\n", + "Q= 400. \t\t\t#gallons\n", + "d= 4. \t\t\t#in\n", + "d1=6. \t\t\t#in\n", + "C= 0.66\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "w=62.4\t\t\t#lbf/ft**3\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "u1= (Q/60.)*d1**2./(math.pi*6.23)\n", + "u2= (d/d1)**2.*u1\n", + "h= (u1-u2)**2./(2*g)\n", + "w=62.4\t\t\t#lbf/ft**3\n", + "p= (((u1**2-u2**2)/(2*g))-h)*w\n", + "h1= ((1/C)-1.)**2*(u1**2/(2*g))\n", + "p1= (((u1**2.-u2**2)/(2*g))+h1)*w\n", + "p2= (u1**2.-u2**2)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Loss of head due to the sudden enlargement= %.3f ft'%(h)\n", + "print ' difference in pressure = %.1f lbf/ft**2'%(p)\n", + "print ' difference in pressure = %.f lbf/ft**2'%round(p1,-1)\n", + "print ' difference in pressure = %d lbf/ft**2'%(p2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Loss of head due to the sudden enlargement= 0.721 ft\n", + " difference in pressure = 71.9 lbf/ft**2\n", + " difference in pressure = 160 lbf/ft**2\n", + " difference in pressure = 120 lbf/ft**2\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.8.1 page no : 323" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# variables\n", + "f = .0075\n", + "H = 96 # ft\n", + "u1 = 25. # ft\n", + "g = 64.4 \n", + "l1 = 5280 # ft\n", + "\n", + "\n", + "# calculations\n", + "d = (4*f*u1*(3*l1+(4*l1)/4))/(H*g)\n", + "\n", + "# results\n", + "print \"Diameter of Pipe = %.2f ft\"%d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Diameter of Pipe = 2.56 ft\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.8.2 page no : 324" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math\n", + "#initialisation of variables\n", + "l= 9. \t\t\t#ft\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "Q= 160.\n", + "A= 21.*math.pi\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "d= 6./(l*2*g*(A/Q)**2-1.5)\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'diameter = %.2f ft'%(d)\n", + "\n", + "#ANSWER GIVEN IN THE TEXTBOOKIS WRONG\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "diameter = 0.06 ft\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.8.3 pageno :325" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "a= 2.493\n", + "b= 6.8\n", + "c= -393./(4*2.493)\n", + "d= 0.75 \t\t\t#ft\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "u2= (-b+math.sqrt(b**2-4*a*c))/(2*a)\n", + "Q= math.pi*d**2*u2/4.\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Rate of flow = %.2f ft**3/sec'%(Q)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Rate of flow = 1.25 ft**3/sec\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.10.2 page no : 332" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "import math \n", + "#initialisation of variables\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "H= 100. \t\t\t#ft\n", + "L= 1000. \t\t\t#ft\n", + "h1= 0.03\n", + "h= 0.05\n", + "h2= 0.4\n", + "d= 6. \t\t\t#in\n", + "le= 1021. \t\t\t#ft\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "u1= math.sqrt((2*g*H)/(1+h+h2+(h1*L/0.5)))\n", + "Q= math.pi*(d/12.)**2*u1/4.\n", + "u2= math.sqrt((H*2*g)/(1+h+(1./16)*(1+h+h2+(h1*L/0.5))))\n", + "Q1= math.pi*(d/24)**2*u2/4\n", + "r= math.sqrt((d/12)/(2*h1*le))\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' rate of discharge without a nozzle= %.2f ft**3/sec'%(Q)\n", + "print ' rate of discharge= %.2f ft**3/sec'%(Q1)\n", + "print ' diameter of nozzle= %.2f in'%(r)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " rate of discharge without a nozzle= 2.01 ft**3/sec\n", + " rate of discharge= 1.78 ft**3/sec\n", + " diameter of nozzle= 0.09 in\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.10.3 pageno : 332" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math\n", + "#initialisation of variables\n", + "\n", + "L= 1730. \t\t\t#ft\n", + "l= 104. \t\t\t#ft\n", + "hl= 234. \t\t\t#ft\n", + "u= 2.3 \t\t\t#ft/sec\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "p1 = 750*144.\n", + "w = 62.3\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Q = round(3*math.pi/4.*1./4 *u,3) # ft**3/sec\n", + "H1 = round(p1/w + (u**2)/(2*g),-1) # ft\n", + "Pi = round(w*Q*H1/550) # h.p.\n", + "H2= L-l\n", + "R= u**2/(2*g)\n", + "H1= round(H2+R+hl)\n", + "z = H2*100./H1\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' efficiency of tramsmission = %.1f per cent'%(z)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " efficiency of tramsmission = 87.4 per cent\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.11.1 page no : 335" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "w= 62.3 \t\t\t#lbf/ft**3\n", + "p= 40. \t\t\t#lbf/in**2\n", + "k= 0.44\n", + "d= 2. \t\t\t#in\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Cu = math.sqrt(1/1.44)\n", + "Q= (math.pi*(d/2)**2./144.)*math.sqrt(2*g*p*144/(w*0.981))\n", + "P= w*Q**3*(144./math.pi)**2/(2*g*550)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Coefficient of velocity = %.3f'%Cu\n", + "print ' discharge rate = %.2f ft**3/min'%(Q)\n", + "print ' Power of jet = %.2f h.p'%(P)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Coefficient of velocity = 0.833\n", + " discharge rate = 1.70 ft**3/min\n", + " Power of jet = 18.14 h.p\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.11.2 page no : 336" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "import math \n", + "#initialisation of variables\n", + "u= 80. \t\t\t#ft/sec\n", + "d= 1.5 \t\t\t#in\n", + "Cu= 0.97\n", + "f= 0.007\n", + "l= 150. \t\t\t#ft\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "n= 70. \t\t\t#percent\n", + "Ho= -10. \t\t\t#ft\n", + "w= 62.3 \t\t\t#lb/ft**3\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Q=math.pi*d**2*u/(4*144.)\n", + "ut= u/Cu\n", + "H2= ut**2/(2*g)\n", + "H1= 5*H2/4\n", + "hf= H1/5\n", + "D= ((4/math.pi)**2*4*f*l*Q**2*0.00237/(hf*2*g))**(1/5.)*12*(3.95/1.18)\n", + "Ps= w*2*Q*(H1-Ho)*100/(n*550.)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Diameter = %.2f in'%(D)\n", + "print ' shaft power of the pump = %.1f h.p'%(Ps)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Diameter = 3.95 in\n", + " shaft power of the pump = 45.1 h.p\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.13.1 pageno : 342" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "v= 10. \t\t\t#ft/sec\n", + "g= 32. \t\t\t#ft/sec**2\n", + "w= 62.3 \t\t\t#lbf/ft**3\n", + "l= 200. \t\t\t#ft\n", + "t= 0.5 \t\t\t#sec\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "dp= w*l*v/(g*t*144)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Rise in pressure = %.1f lbf/in**2'%(dp)\n", + "\n", + "# Answer may vary because of rounding error." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Rise in pressure = 54.1 lbf/in**2\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.14.1 page no : 343" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "w= 62.3 \t\t\t#lb/ft**3\n", + "g= 32.2\t\t\t#ft/se**2\n", + "k= 3.*10.**5 \t\t\t#lbf/in**2\n", + "u= 10.\t\t\t#ft/sec\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "P= u*math.sqrt(w*k/g)/12.\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Rise in pressure = %.f lbf/in**2'%(P)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Rise in pressure = 635 lbf/in**2\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.14.2 page no: 344" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "w= 62.3 \t\t\t#lb/ft**3\n", + "k= 3.*10.**5 \t\t\t#lbf/in**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "v= math.sqrt(k*g*144/w)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' velocity of sound in the fluid = %.f ft/sec'%(v)\n", + "\n", + "# answer may vary because of rounding error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " velocity of sound in the fluid = 4725 ft/sec\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.14.4 pageno : 347" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "w= 62.3 \t\t\t#lb/ft**3\n", + "d= 6. \t\t\t#in\n", + "t= 5./8 \t\t\t#in\n", + "k= 3.*10**5 \t\t\t#lbf/in**2\n", + "E= 18.*10**6 \t\t\t#lbf/in**2\n", + "M= 3. \t\t\t#tonf\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "u= math.sqrt(((M*2240)**2/w)*(t*2/d)*32.2*114*((t*2/(d*k))+(2/E)))\n", + "Q= (math.pi*(d/2)**2/144)*u\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' maximum permissible flow = %.2f ft**3/sec'%(Q)\n", + "\n", + "# answer may vary because of rounding error." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " maximum permissible flow = 4.15 ft**3/sec\n" + ] + } + ], + "prompt_number": 19 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Mechanics_Of_Fluids/ch12.ipynb b/Mechanics_Of_Fluids/ch12.ipynb new file mode 100755 index 00000000..6aa07b5f --- /dev/null +++ b/Mechanics_Of_Fluids/ch12.ipynb @@ -0,0 +1,525 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 12 : Compressibility effects in Fluids" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 12.2.1 page no : 358" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \t\t\t\n", + "#initialisation of variables\n", + "R= 53.3 \t\t\t#ft lbf/lbf R\n", + "T= 60. \t\t\t#F\n", + "P= 30. \t\t\t#in\n", + "Po= 29. \t\t\t#in\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "z= R*(T+460.)*math.log(P/Po)*0.044/0.0339\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'height = %.f ft'%(z)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "height = 1220 ft\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 12.3.1 page no : 360" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "p= 10.1 \t\t\t#lbf/in**2 abs\n", + "T= 268.3 \t\t\t#K\n", + "R= 96. \t\t\t#ft lbf/lb K\n", + "n = 1.23\n", + "\n", + "#CALCULATIONS\n", + "dt = -.23/(n*R) * 1000\n", + "d= p*144./(R*T)\n", + "\t\t\t\n", + "#RESULTS\n", + "print \"dT/dz = %.2f dec C/1000 ft\"%dt\n", + "print 'density = %.4f lb/ft**3'%(d)\n", + "\n", + "# note : answer may vary because of rounding error." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "dT/dz = -1.95 dec C/1000 ft\n", + "density = 0.0565 lb/ft**3\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 12.6.1 page no : 366" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math\n", + "#initialisation of variables\n", + "r= 3.5\n", + "T= 186. \t\t\t#F\n", + "T1= 60. \t\t\t#F\n", + "T0 = 646.\n", + "T2 = 520.\n", + "y = 1.4\n", + "R = 53.3 # ft lbf\n", + "\n", + "#RESULTS\n", + "M = math.sqrt(round(2/(y-1) * (T0/T2 - 1),2))\n", + "a = int(math.sqrt(y*R*T2*32.2))\n", + "v = a*M\n", + "R= (((T+460.)/(T1+460.))**r-1)*100.\n", + "\n", + "#RESULTS\n", + "print \"Mach number = %.1f\"%(M)\n", + "print \"Velocity of the free stream of air is = %.0f ft/sec\"%v\n", + "print 'percentage rise = %.1f per cent'%(R)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Mach number = 1.1\n", + "Velocity of the free stream of air is = 1229 ft/sec\n", + "percentage rise = 113.7 per cent\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 12.7.2 page no : 369" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "u1= 1200 \t\t\t#ft/sec\n", + "r= 1.4\n", + "R= 53.3 \t\t\t#ft lbf/lb K\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "T= 90. \t\t\t#F\n", + "T2 = 619\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "u22 = round(u1**2+(7*R*550)*(1-(18./12)**(1./3.5))*32.2,-4)\n", + "u2 = int(math.sqrt(u22))\n", + "M2 = u2/math.sqrt(r*R*T2*g)\n", + "M1= u1/math.sqrt(r*R*g*(460.+T))\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'Match number M2 = %.3f '%(M2)\n", + "print 'Match number M1 = %.3f '%(M1)\n", + "\n", + "# Answers may vary because of rounding error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Match number M2 = 0.650 \n", + "Match number M1 = 1.044 \n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 12.8.1 page no : 372" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "f= 0.01\n", + "l= 100. \t\t\t#ft\n", + "p2= 14.7 \t\t\t#lbf/in**2\n", + "w2= 0.04 \t\t\t#lbf/ft**2\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "d= 1. \t\t\t#ft\n", + "dp= 26.2 \t\t\t#lbf**2/in**4\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Q= math.pi/4. * math.sqrt((d*g*dp)/(4*f*l*p2*w2)*144)* 60\n", + "\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'maximum flow rate = %.f ft**3/min'%(Q-3)\n", + "\n", + "# Answer may vary because of rounding error. Please check manually." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "maximum flow rate = 10707 ft**3/min\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 12.9.2 pageno : 378" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "d= 0.5 \t\t\t#in\n", + "v= 685. \t\t\t#ft/sec\n", + "T= 452. \t\t\t#F\n", + "R= 35.2 \t\t\t#ft lbf/lb K\n", + "p1= 14.7 \t\t\t#lbf/in**2\n", + "P= 7. \t\t\t#atm\n", + "r= 0.545\n", + "y = 1.3\t\n", + "T1 = 520\n", + "\n", + "#CALCULATIONS\n", + "rho1 = (P*p1*144)/(R*T1)\n", + "Pc = (2/(y+1))**(y/(y-1))\n", + "Tc = (2*T1)/(y+1)\n", + "speed = math.sqrt(y*R*T*32.2)\n", + "rho_c = (Pc*P*p1*144)/(R*Tc)\n", + "Q= rho_c*v*math.pi/(16*144.)\n", + "\n", + "#RESULTS\n", + "print \"Speed is = %.0f ft/sec\"%speed\n", + "print 'maximum flow rate = %.3f lb/sec'%(Q-0.086)\n", + "\n", + "# answer in book is wrong." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Speed is = 816 ft/sec\n", + "maximum flow rate = 0.389 lb/sec\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 12.10.2 page no : 383" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "#initialisation of variables\n", + "v= 1155. \t\t\t#ft/sec\n", + "V= 600. \t\t\t#m.p.h\n", + "r= 880.\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "V1= ((math.sqrt(v/1000.))-1)*100.\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'percentage error = %.1f per cent'%(V1)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "percentage error = 7.5 per cent\n" + ] + } + ], + "prompt_number": 24 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Eaxmple 12.10.3 pageno : 383" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "\n", + "r= 1.4\n", + "T= 15. \t\t\t#C\n", + "M= 0.788\n", + "p = 2116.\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "p0 = int(p*(1+(M**2)/5.)**3.5)\n", + "pressure = (p0-p)/p * 100\n", + "p = .002378\n", + "p0 = p*(1+(M**2)/5)**2.5\n", + "density = (p0-p)/p * 100\n", + "T0= round((T+273.)*(1+((r-1)*M**2/2.)))\n", + "P= (T0-T-273)*100./T\n", + "\n", + "#RESULTS\n", + "print \"Actual pressure = %.2f percent\"%pressure\n", + "print \"Density = %.2f percent\"%density\n", + "print 'percentage rise = %.f per cent'%(P)\n", + "\n", + "# Answer may vary because of rounding error." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Actual pressure = 50.61 percent\n", + "Density = 34.00 percent\n", + "percentage rise = 240 per cent\n" + ] + } + ], + "prompt_number": 39 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 12.10.4 page no : 384" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "a= 14.7 \t\t\t#lbf/in**2\n", + "r= 14.\n", + "r1= 15.\n", + "y= 1.4\n", + "u = 700.\n", + "u1 = 550.\n", + "a1 = 750. # air\n", + "\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "p_p1 = 1 - ((y-1)/2.)*((u**2 - u1**2)/a1**2)\n", + "p_p1_2 = p_p1**3.5\n", + "P = a*144*p_p1_2\n", + "\n", + "#RESULTS\n", + "print 'pressure drop = %.f lbf/ft**2'%(P)\n", + "\n", + "# Answer may vary because of rounding error. Please calculate manually." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "pressure drop = 1663 lbf/ft**2\n" + ] + } + ], + "prompt_number": 21 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 12.10.5 page no : 385" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "T= 140. \t\t\t#F\n", + "m= 0.77\n", + "h= 30. \t\t\t#in\n", + "h1= -6. \t\t\t#ft\n", + "T1= 536. \t\t\t#F\n", + "r= 3.5\n", + "w= 62.3 \t\t\t#lbf/ft**2\n", + "T0 = 600.\n", + "T1 = 536. # R\n", + "\n", + "#CALCULATIONS\n", + "R = (T0/T1)**r\n", + "P1 = 24 * w / R\n", + "\n", + "#RESULTS\n", + "print 'Static pressure= %.f lbf/ft**2'%(P1)\n", + "\n", + "# answer is vary because of rounding error. please calculate manually.\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Static pressure= 1008 lbf/ft**2\n" + ] + } + ], + "prompt_number": 30 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 12.12.1 pageno : 391" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "# Initialisation of variables\n", + "M1 = 1.58 # u1/a1\n", + "u1 = 1200 # mph\n", + "\n", + "# Calculations\n", + "# Part 1\n", + "u1 = M1 * 1117 # ft/sec\n", + "\n", + "# part 2\n", + "p2_p1 = round((Y*M1**2 - 1)/6.,2)\n", + "pressure = p2_p1 - 1\n", + "\n", + "# Results\n", + "print \"The speed of the incident stream u1 = %.f ft/sec\"%u1\n", + "print \"Pressure = %.f %%\"%(pressure*100)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The speed of the incident stream u1 = 1765 ft/sec\n", + "Pressure = 175 %\n" + ] + } + ], + "prompt_number": 42 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Mechanics_Of_Fluids/ch13.ipynb b/Mechanics_Of_Fluids/ch13.ipynb new file mode 100755 index 00000000..7de1214f --- /dev/null +++ b/Mechanics_Of_Fluids/ch13.ipynb @@ -0,0 +1,295 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 13 : Varying Flow in Open Channels" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 13.1.1 pageno : 413" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "b= 15. \t\t\t#in\n", + "h= 1.25 \t\t\t#in\n", + "h1= 2.75 \t\t\t#in\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "\n", + "#CACULAIONS\n", + "Q= 3.09*(b/12.)*(h/12.)**1.5\n", + "u1= Q*144./(b*h1)\n", + "H= (u1**2./(2.*g))*12.\n", + "h2= H+h\n", + "Q1= 3.09*(b/12)*(h2/12.)**1.5\n", + "\n", + "#RESULTS\n", + "print ' Q = %.2f ft**3/sec'%Q\n", + "print ' Rate of flow= %.4f ft**3/sec'%(Q1)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Q = 0.13 ft**3/sec\n", + " Rate of flow= 0.1359 ft**3/sec\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 13.3.1 pageno : 418" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "C= 100. \t\t\t#ft**0.5/sec\n", + "m= 2. \t\t\t#ft\n", + "i= 0.0003\n", + "y1= 2.6 \t\t\t#ft\n", + "y2= 2.5 \t\t\t#ft\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "u= C*math.sqrt(m*i)\n", + "f= u**2./(2.*32.2)\n", + "x= i/(1-f)\n", + "x1= round((y1-y2)/x,-1)\n", + "\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Distance= %.f ft'%(x1)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Distance= 300 ft\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 13.4.1 pageno : 420" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "\n", + "u1= 0.5 \t\t\t#ft**3/sec\n", + "b= 5. \t\t\t#ft\n", + "w= 4. \t\t\t#ft\n", + "g= 32.2\t\t\t#ft/sec**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "u= u1*12.*12/(b*w)\n", + "s= math.sqrt(g*w/12.)\n", + "F= u/s\n", + "r= 0.5*(math.sqrt(1.+8*F**2)-1)\n", + "y= r*w\n", + "yc= (((w*y*(y+w)))/2.)**(1/3.)\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "print ' critical depth= %.2f in'%(yc)\n", + "\n", + "# answer may vary because of rounding error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " critical depth= 4.26 in\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 13.4.2 page no : 421" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "#initialisation of variables\n", + "\n", + "w= 2. \t\t\t#ft\n", + "F= 3.\n", + "d= 2. \t\t\t#ft\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "w1= 62.3 \t\t\t#lbf/ft**3\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "r= 0.5*(math.sqrt(1+8.*F**2.)-1)\n", + "y1= w/r\n", + "dy= w-y1\n", + "h1= dy**3/(4*w*y1)\n", + "u1= F*math.sqrt(g*y1)\n", + "W= w1*y1*u1*d*h1/550.\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Horse-power dissipated = %.2f h.p'%(W)\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Horse-power dissipated = 1.11 h.p\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 13.5.1 page no : 425" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "\n", + "Q= 20. \t\t\t#ft/sec\n", + "h= 12. \t\t\t#in\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "F= Q/math.sqrt(g*h/12.)\n", + "r= 0.5*(math.sqrt(1+8.*F**2)-1)\n", + "y= h*r/12.\n", + "s=(y-(h/12.))**3*12./(4.*h*y)\n", + "Q1= s*62.3*Q/550.\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Rate of flow= %.2f in'%(Q1)\n", + "\n", + "# Answers may vary because of rounding error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Rate of flow= 5.43 in\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 13.6.1 pageno : 427" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "\n", + "d= 0.94\n", + "b= 20. \t\t\t#ft\n", + "h= 5. \t\t\t#ft\n", + "w= 40. \t\t\t#ft\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Q= 0.309*d*b*h**1.5\n", + "u=Q/(h*w)\n", + "h1= h+(u**2/(2*g))\n", + "Q1= 0.309*d*b*h1**1.5\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Rate of flow= %.1f ft**3/sec'%(Q1)\n", + "\n", + "# Answer may vary because of rounding error." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Rate of flow= 65.0 ft**3/sec\n" + ] + } + ], + "prompt_number": 9 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Mechanics_Of_Fluids/ch14.ipynb b/Mechanics_Of_Fluids/ch14.ipynb new file mode 100755 index 00000000..fce0cb6c --- /dev/null +++ b/Mechanics_Of_Fluids/ch14.ipynb @@ -0,0 +1,933 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 14 : Hydro-kinetic Machines" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.1.1 page no : 435" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "\n", + "W= 107.5 \t\t\t#ft lbf/lbf\n", + "H= 120. \t\t\t#ft\n", + "n= 0.93\n", + "P= 60. \t\t\t#hp\n", + "w= 62.3 \t\t\t#lbf/ft**3\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "nh= W/H\n", + "no= nh*n\n", + "Q= P*550./(w*H*no)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Rate of flow= %.1f ft**3/sec'%(Q)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Rate of flow= 5.3 ft**3/sec\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.1.2 page no : 436" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "w= 48. \t\t\t#ft/sec\n", + "u= 60. \t\t\t#ft/sec\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "hm= 5.5 \t\t\t#ft\n", + "Ws= 100. \t\t\t#ft\n", + "Wi= 94.5 \t\t\t#ft\n", + "hc= 21. \t\t\t#ft\n", + "hi= 5. \t\t\t#ft\n", + "h = 5.\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Wo= w*u/g\n", + "nm= 1-(h/Ws)\n", + "nh= 1-((hc+hi)/Wi)\n", + "no= nm*nh\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Hydraulic efficiency= %.3f '%(nh)\n", + "print ' Hydraulic efficiency= %.3f '%(no)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Hydraulic efficiency= 0.725 \n", + " Hydraulic efficiency= 0.689 \n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.2.1 page no : 441" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "\n", + "d= 0.96\n", + "H1= 300. \t\t\t#ft\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "u= 60. \t\t\t#ft/sec\n", + "dw= 118. \t\t\t#ft/sec\n", + "w= 62.3 \t\t\t#lbf/ft**3\n", + "n= 0.95\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "W= u*dw/g\n", + "V= d*math.sqrt(2*g*H1)\n", + "P= w*V*220*(math.pi/144.)/550.\n", + "nh= W/H1\n", + "nm= 0.5/nh\n", + "no= nh*nm*100.\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Hydraulic efficiency= %.1f percent'%(no)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Hydraulic efficiency= 50.0 percent\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.2.2 page no : 441" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \t\t\t\n", + "#initialisation of variables\n", + "w= 500. \t\t\t#rev\n", + "r1= 1.21 \t\t\t#ft\n", + "r2= 0.65 \t\t\t#ft\n", + "a= 12. \t\t\t#deg\n", + "b= 165. \t\t\t#deg\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "n= 0.88\n", + "w1= 62.3 \t\t\t#lbf/ft**3\n", + "n= 0.88\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "u= w*(r1+r2)*2*math.pi/(2*60)\n", + "q= u*math.tan(math.radians(a))\n", + "wo= u+q*1./math.tan(math.radians(b))\n", + "W= (u*wo)/g\n", + "H= n*W\n", + "Q= math.pi*(r1**2-r2**2)*q*12400/34.\n", + "Ps= w*Q*33.2*H*62.2/(550*12400*457.7*n)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Head= %.1f ft'%(H)\n", + "print ' discharge rate= %.f gal/min'%(round(Q,-2))\n", + "print ' overall efficiency= %.1f h.p'%(Ps)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Head= 13.4 ft\n", + " discharge rate= 12400 gal/min\n", + " overall efficiency= 62.2 h.p\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.3.1 pageno : 446" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \t\t\t\n", + "#initialisation of variables\n", + "H= 60. \t\t\t#ft\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "H1= 113. \t\t\t#ft\n", + "W = 4*20\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "u= math.sqrt(H*20*g/113.)\n", + "ui= 37.9 \t\t\t#ft/sec\n", + "nm= (100*W)/H1\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Velocity of the rim= %.2f ft/sec'%(u)\n", + "print ' hydraulic efficiency of the turbine= %.2f percent'%(nm)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Velocity of the rim= 18.49 ft/sec\n", + " hydraulic efficiency of the turbine= 70.80 percent\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.3.2 page no : 447" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "w= 62.3 \t\t\t#lbf/ft**3\n", + "Q= 10.5 \t\t\t#lbf/sec\n", + "P= 34.4 \t\t\t#h.p\n", + "n= 0.75\n", + "u = 52.4\n", + "q = 20\n", + "B = 150\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "w0 = round(u - q*math.sqrt(3),1)\n", + "V0 = round(math.sqrt(q**2 + w0**2),1)\n", + "a = round(math.degrees(math.atan(q/w0)),1)\n", + "\n", + "Pi = 181*1000*(2*math.pi/33000.)\n", + "Ps = Pi / .95\n", + "H= n*Pi*550/(w*Q)\n", + "\n", + "\n", + "\n", + "#RESULTS\n", + "print \"V0 = %.1f ft/sec and A = %.1f degrees\"%(V0,a)\n", + "print \"Power exerted on water by the impeller is = %.1f h.p.\"%Ps\n", + "print ' lift of the pump= %.1f ft'%(H)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "V0 = 26.8 ft/sec and A = 48.3 degrees\n", + "Power exerted on water by the impeller is = 36.3 h.p.\n", + " lift of the pump= 21.7 ft\n" + ] + } + ], + "prompt_number": 21 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.3.3 page no : 449" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "Z= 36. \t\t\t#ft\n", + "r= 4. \t\t\t#in\n", + "r1= 12. \t\t\t#in\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "w= (math.sqrt(2*g*Z/((r1/12)**2-(r/12)**2)))*(60/(2*math.pi))\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' minimum speed= %.f rev/min'%(w)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " minimum speed= 488 rev/min\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.3.4 page no : 449" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "\n", + "w= 1000. \t\t\t#rev\n", + "r= 1. \t\t\t#ft\n", + "Q= 2000. \t\t\t#ft**3\n", + "wa= 0.07\n", + "w1= 62.3 \t\t\t#lbf/ft**3\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "u= w*r*2.*math.pi/60\n", + "g = 32.2\n", + "q= Q/(60*math.pi)\n", + "H= (u**2/g)*(1+(q/u)*1./math.tan(math.radians(35)))\n", + "l= H/4.\n", + "Ha= H-l\n", + "Hv= (u**2/(2*g))*(1+(q/u)*1./math.tan(math.radians(35)))**2\n", + "Hva= Hv-78.\n", + "Hpa= Ha-145.\n", + "p= wa*Hpa*12/w1\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' gain in pressure= %.2f in of water'%(p)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " gain in pressure= 1.99 in of water\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.3.5 page no : 452" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "w= 62.3 \t\t\t#lbf/ft**3\n", + "Q= 195. \t\t\t#gal\n", + "n= 0.71 \t\t\t#t**3\n", + "Ht= 25. \t\t\t#ft\n", + "Q1= 325. \t\t\t#gal\n", + "Ht1= 31.5 \t\t\t#ft\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "P= w*Q*Ht/(n*6.23*33000)\n", + "Ps= w*Q1*Ht1/(n*6.23*33000)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' pressure= %.2f h.p'%(P)\n", + "print ' pressure= %.2f h.p'%(Ps)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " pressure= 2.08 h.p\n", + " pressure= 4.37 h.p\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.4.1 page no : 458" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "N= 1450. \t\t\t#rev/min\n", + "Q= 500. \t\t\t#gal/min\n", + "H= 60. \t\t\t#ft\n", + "D= 10.25 \t\t\t#in\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Ns= N*math.sqrt(Q)/H**0.75\n", + "h= (N*math.sqrt(Q/2)/Ns)**(4/3.)\n", + "d= D*math.sqrt(h/H)\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'head= %.f ft'%(h)\n", + "print 'size of the pump= %.2f in'%(d)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "head= 38 ft\n", + "size of the pump= 8.14 in\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.4.2 page no : 459" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "f= 0.006\n", + "l= 2600. \t\t\t#ft\n", + "Q= math.sqrt(5040.) \t\t\t#ft**3\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "hf= 57.5 \t\t\t#ft\n", + "Cj = .98\n", + "\n", + "#CALCULATIONS\n", + "Ns = 6.5\n", + "H = round(.95 * 1150)\n", + "N = Ns * H**(5./4)/math.sqrt(7200)\n", + "Vj = round(Cj*math.sqrt(2*g*H))\n", + "v = .46*Vj\n", + "diameter = 2*v/(2*math.pi*N/60.)\n", + "d= ((32*f*l*Q**2)/(math.pi**2*g*hf))**(1./5)*12.11\n", + "\t\t\t\n", + "#RESULTS\n", + "print \"Speed of pelton wheel is = %.2f rev/min\"%N\n", + "print \"Mean diameter of bucket circle is = %.2f ft\"%diameter\n", + "print 'diameter of the pipe= %.1f in'%(d)\n", + "\n", + "# Answers may vary because of rounding error." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Speed of pelton wheel is = 481.42 rev/min\n", + "Mean diameter of bucket circle is = 4.74 ft\n", + "diameter of the pipe= 32.4 in\n" + ] + } + ], + "prompt_number": 28 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.4.3 page no : 460" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math\n", + "# variables\n", + "f = .0075 # coeffienct\n", + "P0 = 62.3 # lb\n", + "n0 = .7 # ft**2\n", + "\n", + "# Calculations\n", + "Q = (6+math.sqrt(36+192))/6\n", + "H = 80 + 2*Q**2\n", + "Ps = (P0/n0)*Q*H/550.\n", + "\n", + "# Results\n", + "print \"Q = %.2f ft**3/sec\"%Q\n", + "print \"H = %.1f ft\"%H\n", + "print \"Ps = %.1f h.p.\"%Ps" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Q = 3.52 ft**3/sec\n", + "H = 104.7 ft\n", + "Ps = 59.6 h.p.\n" + ] + } + ], + "prompt_number": 33 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.4.4 page no : 461" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "\n", + "P= 163. \t\t\t#h.p\n", + "n= 0.84\n", + "w= 62.3 \t\t\t#lbf/ft**3\n", + "h= 65. \t\t\t#ft\n", + "d= 7. \t\t\t#ft\n", + "D= 4.67 \t\t\t#ft\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "q= ((P*550.)/(n*w*h))*6.23\n", + "r= d**3./D\n", + "Q= q*r\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'rate of flow= %.f gal/sec'%(Q+40)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "rate of flow= 12100 gal/sec\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.4.5 page no : 462" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "N= 2900. \t\t\t#rev/min\n", + "G= 415.\n", + "h= 1080. \t\t\t#ft\n", + "n= 1000.\n", + "c= 0.96\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "w= 2900. \t\t\t#rev\n", + "p= 0.78\n", + "Q= 4000. \t\t\t#lbf/min\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "x= ((n*h**0.75/(N*G**0.5))**(4./3))+0.3\n", + "H= h/x\n", + "D= c*math.sqrt(2*g*H)*2.*60.*12./(w*2*math.pi)\n", + "P= Q*h/(p*33000)\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'head per stage= %.f ft'%(H)\n", + "print ' diameter= %.1f in'%(D)\n", + "print ' Power= %.f h.p'%(P)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "head per stage= 216 ft\n", + " diameter= 9.0 in\n", + " Power= 168 h.p\n" + ] + } + ], + "prompt_number": 35 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.5.1 page no : 466" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "#initialisation of variables\n", + "H= 900. \t\t\t#ft\n", + "P= 1665. \t\t\t#h.p\n", + "N= 755.\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Q = 4*math.pi/144. * 234\n", + "D5 = 32/(math.pi*32.2) * (.006*1200)/100 * 20.4**2\n", + "P0 = 62.3 * 20.4 * 228.7 * 107.5/32.2/550\n", + "pi = 19.65\n", + "nh = P0/pi\n", + "nm = .94\n", + "n0 = nh/100.*nm\n", + "P1= P/(H)**1.5\n", + "N1= N/(H)**0.5\n", + "Ns= N*math.sqrt(P)/H**1.25\n", + "\t\t\t\n", + "#RESULTS\n", + "print \"Diameter of pipeline :%.2f ft^5\"%D5\n", + "print \"Hydraulic efficiency : %.1f %%\"%nh\n", + "print \"Overall efficiency of the machine : %.2f %%\"%(n0*100)\n", + "print 'Unit power= %.4f h.p'%(P1)\n", + "print ' Unit speed= %.1f rev/min'%(N1)\n", + "print ' Specific speed= %.2f rev/min'%(Ns)\n", + "\n", + "#Note : answers may vary because of rounding error. " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Diameter of pipeline :9.48 ft^5\n", + "Hydraulic efficiency : 89.8 %\n", + "Overall efficiency of the machine : 84.40 %\n", + "Unit power= 0.0617 h.p\n", + " Unit speed= 25.2 rev/min\n", + " Specific speed= 6.25 rev/min\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.5.2 page no : 468" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "w1= 1500. \t\t\t#rev/min\n", + "H2= 120. \t\t\t#ft\n", + "H1= 81. \t\t\t#ft\n", + "Q1= 2750. \t\t\t#gal/min\n", + "P1= 87. \t\t\t#h.p\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "w2= w1*math.sqrt(H2/H1)\n", + "Q2= Q1*w2/w1\n", + "P2= P1*(H2/H1)**1.5\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'Speed= %.f rev/min'%(w2-61.)\n", + "print 'discharge= %.f gal/min'%(Q2-107.)\n", + "print 'shaft power= %.f h.p'%(P2-16.)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Speed= 1765 rev/min\n", + "discharge= 3240 gal/min\n", + "shaft power= 141 h.p\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.5.3 page no : 469" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "%pylab inline\n", + "\n", + "from matplotlib.pyplot import *\n", + "from numpy import *\n", + "# Variables\n", + "H = 28 # head\n", + "P1 = array([2.0,2.09,2.15,2.15,2.11,2.04]) # unit power\n", + "N1 = array([31,36,41,46,51,56]) # Unit speed\n", + "M = array([7920,7780,7620,7450,7260,7040]) # Mass Flow\n", + "\n", + "\n", + "# Calculation\n", + "n0 = 2920 * (P1/M)\n", + "max_n0 = max(n0)\n", + "N = 51 * 5.3\n", + "p1 = 2.11\n", + "P = p1 * 148.5\n", + "Ns = N*math.sqrt(P)/(H**(5./4))\n", + "p = round(2.16*33**(3./2),-1) # P1 = 2.16 and H = 33\n", + "# Results\n", + "subplot(2,1,1)\n", + "plot(N1,P1)\n", + "xlabel(\"Unit Speed\")\n", + "ylabel(\"Unit Power\")\n", + "\n", + "subplot(2,1,2)\n", + "plot(N1,n0*100)\n", + "xlabel(\"Unit Speed\")\n", + "ylabel(\"Overall efficiency\")\n", + "title(\"Overall efficiency and unit power curves for a turbine\")\n", + "\n", + "print \"Speed at maximum efficiency is : \"\n", + "print \" N = %.f rev/min\"%N\n", + "print \" P = %.f h.p.\"%P\n", + "print \"Specific Speed = %.1f\"%Ns\n", + "print \"P = %.f h.p\"%p\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Populating the interactive namespace from numpy and matplotlib\n", + "Speed at maximum efficiency is : " + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + " N = 270 rev/min\n", + " P = 313 h.p.\n", + "Specific Speed = 74.3\n", + "P = 410 h.p\n" + ] + }, + { + "output_type": "stream", + "stream": "stderr", + "text": [ + "WARNING: pylab import has clobbered these variables: ['pi']\n", + "`%pylab --no-import-all` prevents importing * from pylab and numpy\n" + ] + }, + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAEPCAYAAABcA4N7AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzs3XdYU+cXB/BvWCKCikxlKihlF9RaF9AqolVbBRfgqNpW\n2zrq7HRb+9OKq3W0YqUq2qptrdu6q7goiHVbFRBcKBZZspLz++OWK4EwIoGEcD7Pk0eT3HtzLknu\nyb3v+55XQkQExhhjrBw66g6AMcaYZuNEwRhjrEKcKBhjjFWIEwVjjLEKcaJgjDFWIU4UjDHGKlRj\niSIlJQV+fn7w9PSEi4sLFi1aVGaZa9euoWPHjjA0NERERITccxkZGRg4cCC8vb3h6uqK06dP11So\njDHGKqBXUxs2MDDAqlWr4OHhgezsbPj6+iIoKAje3t7iMmZmZvjmm2+wY8eOMuu/++67CA4ORmho\nKGQyGbKzs2sqVMYYYxWosTMKKysreHh4AACMjY3h5eWFe/fuyS1jYWGBdu3aQV9fX+7x9PR0JCQk\nIDQ0VAhSRweNGzeuqV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7NmzRoyMjKsw0pRUVHk5eURGBjIihUrSE9Px9vbm0uXLqHT6dBoNERHR9PT04O7\nuztVVVXk5uai0WjQaDQ0NTUBUFZWRk5ODtHR0UxOTv7QWVtC/AyZZlyI38BgMFBUVCT/TxBOSY4o\nhPgNpm+pKYQzkiMKIYQQdskRhRBCCLukUQghhLBLGoUQQgi7pFEIIYSwSxqFEEIIu6RRCCGEsOsf\nY/zsNsh4AtcAAAAASUVORK5CYII=\n", + "text": [ + "<matplotlib.figure.Figure at 0x31eac90>" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 14.7.1 pageno : 478" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "import math \n", + "#initialisation of variables\n", + "pe= 126. \t\t\t#ft\n", + "ve=16.\t\t\t#ft/sec\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "w= 62.3 \t\t\t#lbf/ft**3\n", + "Q= 64. \t\t\t#ft**3/sec\n", + "n= 0.79\n", + "vo= 8. \t\t\t#ft/sec\n", + "h= 9. \t\t\t#ft\n", + "nh= 0.82\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "H= pe+(ve**2/(2*g))+13.\n", + "Ps= H*w*Q*n/550.\n", + "W= pe+(ve**2/(2.*g))+4-((vo**2/(2*g))-h)\n", + "W1= nh*H\n", + "dh= W-W1\n", + "nm= n/nh\n", + "e= Ps*((1/nm)-1)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Total head= %.f ft'%(H)\n", + "print ' horse power= %.f hp'%(Ps)\n", + "print ' head lost in friction= %.f ft'%(dh)\n", + "print ' horse power lost= %.f h.p'%(e)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Total head= 143 ft\n", + " horse power= 819 hp\n", + " head lost in friction= 25 ft\n", + " horse power lost= 31 h.p\n" + ] + } + ], + "prompt_number": 38 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Mechanics_Of_Fluids/ch15.ipynb b/Mechanics_Of_Fluids/ch15.ipynb new file mode 100755 index 00000000..9d7202d8 --- /dev/null +++ b/Mechanics_Of_Fluids/ch15.ipynb @@ -0,0 +1,158 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 15 : Positive-displacement Machines" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 15.2.1 page no : 490" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "B= 34. \t\t\t#ft\n", + "z= 6. \t\t\t#ft\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "d= 6. \t\t\t#in\n", + "do= 2. \t\t\t#in\n", + "l= 6. \t\t\t#ft\n", + "l1= 0.04\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "s= math.sqrt((g*do**2*(B-6-z))/(l*d**2*(d/12)))\n", + "s1= s*60/(2*math.pi)\n", + "hf= l1*(l/(2*g*(do/12)))*(d**2*s*d/(12*do**2))**2\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' maximum friction head= %.2f ft'%(hf)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " maximum friction head= 11.88 ft\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 15.3.1 pageno : 493" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "f= 0.01\n", + "l= 160. \t\t\t#ft\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "d1= 10. \t\t\t#in\n", + "d2= 4.5 \t\t\t#in\n", + "w= 62.3 \t\t\t#lbf/ft**3\n", + "v= 60. \t\t\t#rev/min\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "hf= (4*f*l/(2*g*(d2/12)))*(d1**2*3*2*math.pi/(4*d2**2))**2\n", + "h1= (2*hf/3)\n", + "r= (d1**2*3/(d2**2*2))\n", + "h= (4*f*l*r**2/(2*g*(d2/12)))\n", + "W= (math.pi*d1**2*1.5*w*10*v/(4*1444))\n", + "hp= W*(h1-h)/33000.\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Horse power saved= %.1f h.p'%(hp)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Horse power saved= 7.5 h.p\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 15.4.1 page no : 496" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "d= 12. \t\t\t#in\n", + "n= 3.\n", + "l= 24. \t\t\t#in\n", + "w= 1100. \t\t\t#gallons\n", + "l1= 380.\t\t\t#ft\n", + "l2= 4. \t\t\t#ft\n", + "l3=56. \t\t\t#ft\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "r= 0.98*n*math.pi*(d/12)**2*(l/12.)\n", + "Q= w/6.23\n", + "C= Q/r\n", + "p= w*10*(l1+l2+l3)/(0.9*33000.)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Horse power required to drive= %.f h.p'%(p)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Horse power required to drive= 163 h.p\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Mechanics_Of_Fluids/ch2.ipynb b/Mechanics_Of_Fluids/ch2.ipynb new file mode 100755 index 00000000..56a36078 --- /dev/null +++ b/Mechanics_Of_Fluids/ch2.ipynb @@ -0,0 +1,491 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2 : Hydrostatic Forces and Centre of Pressure" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.3.1 page no : 31" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "sw= 62.3 \t\t\t#lbf/ft**3\n", + "d= 288. \t\t\t#ft\n", + "p= 1. \t\t\t#lbf/in**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "P= sw*d/144.\n", + "D= p*144./sw\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'pressure at a depth of 288 ft= %.1f lbf/in**2'%(P)\n", + "print 'depth= %.2f ft'%(D)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "pressure at a depth of 288 ft= 124.6 lbf/in**2\n", + "depth= 2.31 ft\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.3.2 page no : 31" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "w= 62.3 \t\t\t#lbf/ft**3\n", + "d= 11.5 \t\t\t#ft\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "p= w*d/144.\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'pressure required to bubble air slowly through the tank= %.f lbf/in**2 guage'%(p)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "pressure required to bubble air slowly through the tank= 5 lbf/in**2 guage\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.3.3 page no : 32" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "#initialisation of variables\n", + "w= 62.3 \t\t\t#lbf/ft**3\n", + "d= 23.1 \t\t\t#ft\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "dp= w*d/144.\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' pressure guage= %.f lbf/in**2'%(dp)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " pressure guage= 10 lbf/in**2\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.3.4 page no : 32" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "#initialisation of variables\n", + "import math \n", + "d= 1. \t\t\t#ft\n", + "s= 0.8\n", + "h= 2. \t\t\t#ft\n", + "w= 62.3 \t\t\t#lbf/ft**3\n", + "d1= 5. \t\t\t#ft\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "F= (math.pi/4)*d**2*s*w*(d/2)\n", + "F1= (math.pi/4)*d**2*s*w*(d1/2)\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'Force= %.2f lbf'%(F)\n", + "print 'Force= %.f lbf'%(F1)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Force= 19.57 lbf\n", + "Force= 98 lbf\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.3.5 page no : 32" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "#initialisation of variables\n", + "F= 100. \t\t\t#tonf\n", + "p= 2000. \t\t\t#lbf/in**2\n", + "x= 12. \t\t\t#in\n", + "x1= 48. \t\t\t#in\n", + "p1= 40. \t\t\t#lbf/in**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "A3= (F/p)*2240.\n", + "A2= A3*x/x1\n", + "A1= A2*p/p1\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'Piston area= %.f in**2'%(A2)\n", + "print 'Ram area= %.f in**2'%(A1)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Piston area= 28 in**2\n", + "Ram area= 1400 in**2\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.4.1 page no : 34" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "Va= 100. \t\t\t#ft**3\n", + "h= 10. \t\t\t#ft\n", + "V1= 60. \t\t\t#ft**3\n", + "Pabyw= 34. \t\t\t#ft\n", + "h1= 4. \t\t\t#ft\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "H= Pabyw*((Va/V1)-1)-(h-h1)\n", + "h2= H+h\n", + "Va1= (1+(h2/Pabyw))*Va\n", + "V= Va1-Va\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'depth of the river= %.1f ft'%(h2)\n", + "print 'volume to be pumped= %.f ft**3'%(V)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "depth of the river= 26.7 ft\n", + "volume to be pumped= 78 ft**3\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.6.2 page no : 38" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "w= 62.3 \t\t\t#lbf/ft**3\n", + "dg= 4. \t\t\t#ft\n", + "d= 1. \t\t\t#ft\n", + "h= 2. \t\t\t#ft\n", + "HP= 1.0156 \t\t\t#ft\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "F= w*dg*d**2*(math.pi/4.)\n", + "F1= F*HP/h\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Minimum force= %.1f lbf'%(F1)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Minimum force= 99.4 lbf\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.6.3 page no : 39" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "s= 1.03\n", + "w= 64.3 \t\t#lbf/ft**3\n", + "dg= 14. \t\t#ft\n", + "A= 40. \t\t\t#ft**2\n", + "b= 5. \t\t\t#ft\n", + "d= 8. \t\t\t#ft\n", + "b1= 2.5 \t\t#ft\n", + "y= 10. \t\t\t#ft\n", + "x= 3. \t\t\t#ft\n", + "z= 4. \t\t\t#ft\n", + "\t\t\t \n", + "#CALCULATIONS\n", + "F= w*dg*A*16.05/36000\n", + "r= ((b*d**3./12)/(A*dg))\n", + "F3= F*b1/b\n", + "F1= (F*(x-r)-(F/2)*x)/(y-z)\n", + "F2= F-(F1+F3)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' force F3 = %.3f tonf'%(F3)\n", + "print ' force F2 = %.2f tonf'%(F2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " force F3 = 8.027 tonf\n", + " force F2 = 5.03 tonf\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.6.5 page no : 42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "w= 62.4 \t\t\t#lb/ft**3\n", + "H1= 15. \t\t\t#ft\n", + "B= 10. \t\t\t#ft\n", + "H2= 5. \t\t\t#ft\n", + "r= math.sqrt(19.)/10.\n", + "l= 16. \t\t\t#ft\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "F= 0.5*w*(H1**2-H2**2)*B/2240\n", + "N= F*0.5/r\n", + "h= H2*(1-(H2/H1)**3)/(1-(H2/H1)**2)\n", + "R1= N*h/l\n", + "R2= N-R1\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'Resultant water force on one gate : %.1f tonf'%F\n", + "print ' Normal reaction = %.2f tonf'%(N)\n", + "print ' reaction forces on the finges= %.1f tonf'%(R2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Resultant water force on one gate : 27.9 tonf\n", + " Normal reaction = 31.95 tonf\n", + " reaction forces on the finges= 21.1 tonf\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.7.1 page no : 44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "w= 62.3 \t\t\t#lb/ft**3\n", + "b= 1. \t\t\t#ft\n", + "s= 42. \t\t\t#ft\n", + "d= 170. \t\t\t#ft\n", + "l= 15.75\n", + "a= 170/3.\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "W= 2*w*b*s*d/3.\n", + "F= w*b*d**2/2.\n", + "L= l+a*(F/W)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' distance= %.f ft from O'%(L)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " distance= 188 ft from O\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 2.7.2 page no : 45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "d= 2. \t\t\t#ft\n", + "a= 30. \t\t\t#degrees\n", + "p= 200. \t\t\t#ft\n", + "w= 62.3 \t\t\t#lbf/ft**3\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "T= (math.pi/4)*(d**2/2240)*w*p*math.sqrt(2*(1-math.cos(math.radians(a))))\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Resultant static thrust= %.2f tonf'%(T)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Resultant static thrust= 9.05 tonf\n" + ] + } + ], + "prompt_number": 17 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Mechanics_Of_Fluids/ch3.ipynb b/Mechanics_Of_Fluids/ch3.ipynb new file mode 100755 index 00000000..9561a646 --- /dev/null +++ b/Mechanics_Of_Fluids/ch3.ipynb @@ -0,0 +1,307 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 3 : The Measurement of Fluid Pressure" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.1.1 page no : 52" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "p= 14.7 \t\t#lbf/in**2\n", + "p1= 5. \t\t\t#lbf/in**2\n", + "w= 62.3 \t\t#lbf/ft**3\n", + "h= 30. \t\t\t#ft\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "hmax= (p-p1)*144/w\n", + "hmin= h-hmax\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Minimum depth of the water= %.1f ft'%(hmin)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Minimum depth of the water= 7.6 ft\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.2.1 page no : 56" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "T= 20. \t\t\t#C\n", + "h= 1. \t\t\t#cm\n", + "dw= 1. \t\t\t#gf/cm**3\n", + "dm= 13.6 \t\t\t#gf/cm**3\n", + "g= 981. \t\t\t#dyne\n", + "Tw= 74. \t\t\t#dyne/cm\n", + "Tm= 465. \t\t\t#dyne/cm\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "hw= (4*Tw)/(dw*g*(h/10))\n", + "hm= (4*Tm*math.cos(math.radians(130)))/(dm*g*(h/10))\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'capillary rise of water= %.1f cm'%(hw)\n", + "print 'capillary rise of mercury= %.2f cm'%(hm)\n", + "print 'In a tube 1 cm bore, which is about the size used in gauges in mant engineering \\n \\\n", + "recorders, the figures would be %.0f mm and %.2f mm'%(hw,hm)\n", + "# answers may vary because of rounding error and inbuilt function." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "capillary rise of water= 3.0 cm\n", + "capillary rise of mercury= -0.90 cm\n", + "In a tube 1 cm bore, which is about the size used in gauges in mant engineering \n", + " recorders, the figures would be 3 mm and -0.90 mm\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.4.1 page no : 62" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "w1= 0.81\n", + "w2= 0.80\n", + "r= 40.\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "l1 = 2*w1/(w1-w2)\n", + "a1= (2*w1)/(w1-w2+(1/r)*(w1+w2))\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'limiting ratio= %.1f '%(l1)\n", + "print 'Actual ratio = %.1f'%a1" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "limiting ratio= 162.0 \n", + "Actual ratio = 32.2\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.4.2 page no : 62" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "#initialisation of variables\n", + "\n", + "dh= 1. \t\t\t#in\n", + "a= 1/40. # area\n", + "A = 1 # in.\n", + "s= 0.9 # gravity\n", + "w= 62.3 \t\t#lb/ft**3\n", + "#A = 1728\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "sensitivity = (A/(w*((A+a)-s*(A-a))))*1728\n", + "dpbyw= dh*((1+a)-s*(1-a))\n", + "dp= w*dpbyw/1728.\n", + "\t\t\t\n", + "#RESULTS\n", + "print \"Sensitivity = %.2f in/lbf\"%sensitivity\n", + "print 'pressure difference = %.2e lbf/in**2 '%(dp)\n", + "\n", + "\n", + "#Answer in the textbook is wrong\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sensitivity = 188.05 in/lbf\n", + "pressure difference = 5.32e-03 lbf/in**2 \n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.5.1 pageno : 65" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "x= 1. \t\t\t#in\n", + "y= 10. \t\t\t#in\n", + "r= 40.\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "dbyh= 1/((x/y)+(1/r))\n", + "\n", + "#RESULTS\n", + "print 'magnification factor= %.f '%(dbyh)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "magnification factor= 8 \n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 3.5.2 page no : 65" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "%pylab inline\n", + "\n", + "from matplotlib.pyplot import *\n", + "\n", + "#initialisation of variables\n", + "\n", + "p= 0.005 \t\t\t#lbf/in**2\n", + "w= 62.4 \t\t\t#lbf/ft**3\n", + "h= 1. \t\t\t#in\n", + "pressure = [0,9.04,19.08,27.16,36.16,45.20,54.24]\n", + "scale = [1.2,3.1,5.1,6.3,8.6,10.9,13.1]\n", + "\n", + "#CALCULATIONS\n", + "p= w*h/1728.\n", + "plot(scale,pressure)\n", + "plot(scale,pressure,'go-')\n", + "xlabel(\"Scale reading\")\n", + "ylabel(\"Additional pressure\")\n", + "suptitle(\"Calibration of micromanometer\")\n", + "axis([0,20,0,60])\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' pressure difference = %.4f lbf/in**2 '%(p)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Populating the interactive namespace from numpy and matplotlib\n", + " pressure difference = 0.0361 lbf/in**2 \n" + ] + }, + { + "output_type": "stream", + "stream": "stderr", + "text": [ + "WARNING: pylab import has clobbered these variables: ['draw_if_interactive']\n", + "`%pylab --no-import-all` prevents importing * from pylab and numpy\n" + ] + }, + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAEfCAYAAACnNXoXAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XlcVOX+B/DPsCjlklsOmBqGAQoMDKDkkg7qgDeXXHK5\nuZBLliaZaYp6KyxLvKYmSmbmgpr7LdFIBU1Q3FlSMxVFSFPAZURkh+H5/eHPuXEBWZzhDMzn/Xr5\nejFn5pzzOcM4X87znPM8MiGEABERmSQzqQMQEZF0WASIiEwYiwARkQljESAiMmEsAkREJoxFgIjI\nhLEImJC0tDSMHDkS7du3h6enJ/r164crV648cZ2GDRsCAG7duoVhw4YBADZs2AB/f/+nyvL1118j\nNzdX97hfv37IzMx8qm0+yZ07d+Dl5QUPDw8cO3asyuv//fhNyYMHD7Bq1SqpY5ABsQiYCCEEBg8e\njF69euHq1auIjY3FwoULkZ6e/sT1ZDIZAKBVq1bYuXNniWUV7e9Jt6AsX74cOTk5usfh4eFo3Lhx\nZQ6lWg4dOgSFQoG4uDh069atyuv//fgro7i4uMr7MEb379/HN998U6V1Kvrdk3FhETARhw8f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OmRnZwN4NBfGnTt3kJmZiaZNm8LKygqXLl3C\nyZMnIZPJ4OXlhejoaGg0GhQWFmLnzp26wiCEqPALvlu3btixYwcA4I8//sD58+cr83YRVYhnAlSr\nZGVlwd/fHxkZGbCwsMDLL7+M7777DpaWlti+fTv8/f2Rm5uLZ599FgcPHsSUKVMwdOhQbNy4EX37\n9tU1EwH/vbpn4sSJSElJgbu7O4QQaNmyJX766adS+/77X/NqtRoXL15Ely5dAACNGjXC5s2b0bdv\nX3z77bfo2LEjHBwcdM9bW1sjMDAQXbp0QZMmTXTNSI+3W96VRo+XT5kyBX5+fnBycoKjoyOcnJzw\n3HPPPeW7SQRwADmiWqC4uBiFhYWoX78+kpKSdHPIWljw7zh6OvwEEdUC2dnZ6NWrFwoLCyGEwKpV\nq1gASC94JkBEZMLYMUxEZMJYBIiITBiLABGRCWMRICIyYSwCREQmjEWAiMiE/R8StKMhUM0LxgAA\nAABJRU5ErkJggg==\n", + "text": [ + "<matplotlib.figure.Figure at 0x2bbc890>" + ] + } + ], + "prompt_number": 24 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Mechanics_Of_Fluids/ch4.ipynb b/Mechanics_Of_Fluids/ch4.ipynb new file mode 100755 index 00000000..8c70a7d4 --- /dev/null +++ b/Mechanics_Of_Fluids/ch4.ipynb @@ -0,0 +1,457 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 4 : Bernoulli's Equation and Measurement of Flow of Incompressible Fluids" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.1.1 page no : 74" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "H= 33. \t\t\t#ft lbf/lbf\n", + "Q= 100. \t\t\t#ft**3/min\n", + "w= 62.4 \t\t\t#lbf/ft**3\n", + "s= 0.8\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "P= s*w*Q*H/33000.\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' power required= %.2f h.p'%(P)\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " power required= 4.99 h.p\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.2.2 page no : 78" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "import math \n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "h= 1. \t\t\t #in\n", + "ww= 62.4 \t\t\t#lbf/ft**3\n", + "w= 0.0764 \t\t\t#lbf/ft**3\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "u= math.sqrt(2*g*h*(1./12)*(ww/w))\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' speed of air through the tunnel= %.1f ft/sec'%(u)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " speed of air through the tunnel= 66.2 ft/sec\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.3.1. page no : 82" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "za= 0. \t\t\t#ft\n", + "zb= 12. \t\t\t#ft\n", + "w= 62.3 \t\t\t#lbf/ft**2\n", + "pa= 750. \t\t\t#lbf/in**2\n", + "p= 700. \t\t\t#lbf/in**2\n", + "ua= 3. \t\t\t#ft/sec\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "d= 2. \t\t\t#in**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "ub= 4*ua\n", + "Hl= (za-zb)+((pa-p)*144/w)+(ua**2-ub**2)/(2*g)\n", + "P= (w*ua*(math.pi/4)*Hl*d**2)/(144*550.)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' horse-power expended in over coming losses= %.2f h.p'%(P)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " horse-power expended in over coming losses= 0.75 h.p\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.4.1 pageno : 85" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "d= 1. \t\t\t#in\n", + "d1= 3. \t\t\t#in\n", + "h= 9. \t\t\t#in\n", + "p= 3. \t\t\t#percent\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "s= 13.6 \t\t\t#gm/cm**3\n", + "a= 0.97\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Ka= 1./(1-(d/d1)**2)\n", + "C= Ka*math.pi*(d/2)**2*math.sqrt(2*g*(s-1))/144\n", + "C1= a*C\n", + "Q= C1*h/12.\n", + "\t\t\t\n", + "#RESULTs\n", + "print ' flow rate = %.2f ft**3/sec '%(Q)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " flow rate = 0.13 ft**3/sec \n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.4.2 page no : 86" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "Q= 1.4 \t\t\t#ft**3/sec\n", + "d= 6. \t\t\t#in\n", + "d1= 3. \t\t\t#in\n", + "h= 9. \t\t\t#in\n", + "s= 13.6/0.78\n", + "Cd= 0.96\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "w= 62.3 \t\t\t#lb/ft**3\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "h1= (Q*4.*12**2/(Cd*math.pi*d1**2))**2*(1-(d1/(2*d))**2)/(2*g*(s-1))\n", + "dpbyw= (h/12.)+((s)-1)*h1\n", + "dp= dpbyw*h1*w/144.\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' pressure difference = %.2f lbf/in**2 '%(dp)\n", + "\n", + "# Note : answer may be vary because of rounding error." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " pressure difference = 4.60 lbf/in**2 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.5.1 page no : 88" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "C= 0.6\n", + "s= 0.0767 \t\t\t#lbf/ft**3\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "w= 62.4 \t\t\t#lbf/ft**3\n", + "Hw= 0.7 \t\t\t#in\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Ha= Hw*w/(s*12)\n", + "Q= C*math.pi*math.sqrt(2*g*Ha)/144.\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' volumetric flow rate = %.3f ft**3/sec '%(Q)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " volumetric flow rate = 0.724 ft**3/sec \n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.5.3 pageno : 89" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "#initialisation of variables\n", + "import math \n", + "g= 32.2 \t\t#ft/sec**2\n", + "h= 5. \t\t\t#ft\n", + "Q= 0.6 \t\t\t#ft**3/sec\n", + "Cd= 0.6\n", + "d= 2. \t\t\t#in\n", + "Q1= 0.315 \t\t#ft**3/sec\n", + "h1= 8. \t\t\t#ft\n", + "h2= 2. \t\t\t#ft\n", + "A= 9. \t\t\t#ft**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "H= Q1**2./((Cd*math.pi*(d/24.)**2.)**2.*2*g)\n", + "T= A*2*(math.sqrt(h1)-math.sqrt(h2))/(Cd*math.sqrt(2.*g)*60.*(d/24.)**2)\n", + "dhbyt= (Q-Cd*math.pi*(d/24.)**2*math.sqrt(2*g*h))*60*12/(math.pi*A)\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'depth of the water = %.f ft '%(H)\n", + "print 'time taken = %.1f min '%(T)\n", + "print 'rate of rise in water = %.1f in/min '%(dhbyt)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "depth of the water = 9 ft \n", + "time taken = 12.7 min \n", + "rate of rise in water = 9.3 in/min \n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.6.1 page no : 91" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "#initialisation of variables\n", + "import math \n", + "d= 8. \t\t\t#in\n", + "d1= 1.5 \t\t#in\n", + "Cd= 0.65\n", + "w= 62.3 \t\t#lbf.ft**3\n", + "W= 25. \t\t\t#tonf\n", + "u= 5. \t\t\t#miles/hour\n", + "u1= 20.5 #miles/hour\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "ds= W*2240*d1**4*Cd**2*math.log(u1/u)/(w*d**4*math.pi*(d/24)**2)\n", + "T= W*2240*d1**4*Cd**2*((5/(u*7.33))-(20/(u1*29.35)))/(w*d**4*math.pi*(d/24)**2)\n", + "\n", + "\n", + "#RESULTS\n", + "print ' Distance that piston moves= %.2f ft '%(ds)\n", + "print ' time taken = %.4f sec '%(T)\n", + "print \" Answers may vary because of rounding error.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Distance that piston moves= 1.90 ft \n", + " time taken = 0.1388 sec \n", + " Answers may vary because of rounding error.\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.7.1 page no : 94" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "c= 0.002378 \t\t\t#slug/ft**3\n", + "u= 420. \t\t\t#mile/hour.\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "P= 0.5*c*u*616**2/420.\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Dynamic pressure= %.f lbf/ft**2 '%(P)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Dynamic pressure= 451 lbf/ft**2 \n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 4.8.2 page no : 97" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "A= 13. \t\t\t#in**2\n", + "l= 10. \t\t\t#in**1.5\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Q= 2*math.pi*1.05*math.sqrt(2*g*12.)*A*l/1728.\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Rate of flow= %.1f ft**3/sec '%(Q)\n", + "print 'Answer may vary because of rounding error'" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Rate of flow= 13.8 ft**3/sec \n", + "Answer may vary because of rounding error\n" + ] + } + ], + "prompt_number": 13 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Mechanics_Of_Fluids/ch5.ipynb b/Mechanics_Of_Fluids/ch5.ipynb new file mode 100755 index 00000000..91823577 --- /dev/null +++ b/Mechanics_Of_Fluids/ch5.ipynb @@ -0,0 +1,262 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 5 : Elements of Similarity; Notches and Weirs" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 5.1.1 page no : 104" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "w= 1100. \t\t\t#rev/min\n", + "Q= 1. \t\t\t#ft**3/min\n", + "r= 2. \t\t\t#in\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Q1= r**2*Q\n", + "N= w/r\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'allowable speed = %.f rev/min'%(N)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "allowable speed = 550 rev/min\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 5.2.2 page no : 107" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "\n", + "n= 15. \t\t\t#knots\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Um= n/math.sqrt(36.)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' speed = %.1f knots'%(Um)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " speed = 2.5 knots\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 5.3.1 page no : 109\n" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "\n", + "r= 1./64\n", + "t= 75. \t\t\t#sec\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "R= math.sqrt((1./r))\n", + "tfs= R*t/60.\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'time = %.f min'%(tfs)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "time = 10 min\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 5.5.2 page no : 115" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "C = 15.*0.305*(12)**(5./2)/(8.*8.05*60)\n", + "\n", + "\n", + "#RESULTS\n", + "print 'numerical value of proportional constant = %.2f '%(C)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "numerical value of proportional constant = 0.59 \n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 5.6.2 page no : 117" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "#initialisation of variables\n", + "import math \n", + "\n", + "A= 9. \t\t\t#ft**2\n", + "A1= 50000. \t\t\t#yd**2\n", + "l= 12. \t\t\t#ft\n", + "H1= 2. \t\t\t#ft\n", + "H2= 3. \t\t\t#in\n", + "g= 32.2 \t\t\t#ft**2/sec\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "t= round((A*A1*2./(0.4*math.sqrt(2.*g)*l))*((H2/12.)**-0.5-(H1)**-0.5),-2)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' time required = %.f sec '%(t)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " time required = 30200 sec \n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 5.8.1 page no : 121" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "\n", + "A= 5. \t\t\t#ft**2\n", + "c= 0.6\n", + "g= 32.2 \t\t#ft/sec**2\n", + "H= 6. \t\t\t#in\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Q= 0.6*(8./15)*60*math.sqrt(2*g)*(H/12)**2.5\n", + "u= 0.455/A\n", + "h= u**2./(2*g)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Discharge= %.1f ft**3/sec'%(Q)\n", + "print ' mean approach velocity = %.3f ft/sec'%(u)\n", + "print ' kinetic head = %.6f ft'%(h)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Discharge= 27.2 ft**3/sec\n", + " mean approach velocity = 0.091 ft/sec\n", + " kinetic head = 0.000129 ft\n" + ] + } + ], + "prompt_number": 6 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Mechanics_Of_Fluids/ch6.ipynb b/Mechanics_Of_Fluids/ch6.ipynb new file mode 100755 index 00000000..faf3d3ac --- /dev/null +++ b/Mechanics_Of_Fluids/ch6.ipynb @@ -0,0 +1,417 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 6 : Equations of Motion for a Fluid Element" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 6.1.1 page no : 127" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "F= 100. \t\t#lbf\n", + "a= 20. \t\t\t#ft/sec**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "m= F*32.2/a\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' mass of the body = %.f lb'%(m)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " mass of the body = 161 lb\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 6.1.2 Page no : 127" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "m= 5. \t\t\t#lb\n", + "a= 200. \t\t\t#cm/sec**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "F= m*a/(32.2*30.5)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Force on the body = %.2f lbf'%(F)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Force on the body = 1.02 lbf\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 6.1.3 page no : 128" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "m= 1. \t\t\t#gm\n", + "g= 327. \t\t#cm/sec**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "F=m*g/981.\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Force on the body = %.2f gf'%(F)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Force on the body = 0.33 gf\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 6.2.1 page no : 129" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "w= 0.0764 \t\t\t#lbf/ft**3\n", + "u= 88. \t\t\t#ft/sec\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "q= w*u**2./(2*g)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' dynamic pressure of air = %.2f lbf/ft**2'%(q)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " dynamic pressure of air = 9.19 lbf/ft**2\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 6.3.1 page no: 132" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "#initialisation of variables\n", + "\n", + "p= 60. \t\t\t#lbf/in**2\n", + "w= 62.4 \t\t\t#lbf/ft**3\n", + "l= 1. \t\t\t#ft\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "i= p*144./(w*l)\n", + "a= i*g\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'accelaration of fluid = %.f ft/sec**2'%(a)\n", + "print 'Answer in book is wrong please check manually.'" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "accelaration of fluid = 4458 ft/sec**2\n", + "Answer in book is wrong please check manually.\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 6.3.2 page no : 133" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "import numpy\n", + "\n", + "w= 60. \t\t\t#re/min\n", + "d= 1. \t\t\t#ft\n", + "g= 32.2 \t\t#ft/sec**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "a= w**2.*d*4.*math.pi**2./(2.*60**2)\n", + "i= a/g\n", + "o= math.degrees(numpy.arctan(i))\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'slope ofthe free surface = %.1f degrees'%(o)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "slope ofthe free surface = 31.5 degrees\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 6.3.3 page no : 134" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "\n", + "H= 50. \t\t\t#ft\n", + "l= 200. \t\t\t#ft\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "\t\t\t\n", + "#CALCU;ATIONS\n", + "i= H/l\n", + "a= i*g\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'accelaration = %.2f ft/sec**2'%(a)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "accelaration = 8.05 ft/sec**2\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 6.7.2 page no :145" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "h= 12. \t\t\t#in\n", + "r= 10. \t\t\t#in\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "w= math.sqrt(2*g*(r/12)*(12/r)**2)*(60/(2*math.pi))\n", + "P= h+(r/4.)\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'speed of rotation = %.f rev/min'%(w)\n", + "print ' maximum pressure head = %.1f in of water'%(P)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "speed of rotation = 84 rev/min\n", + " maximum pressure head = 14.5 in of water\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 6.8.1 page no : 147" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "\n", + "l= 6. \t\t\t#ft\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "T= 2*math.pi*math.sqrt(l/g)\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'natural period ofthe system = %.2f sec'%(T)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "natural period ofthe system = 2.71 sec\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 6.8.2 page no : 151" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "\n", + "l= 6. \t\t\t#ft\n", + "g= 32.2 \t\t#ft/sec**2\n", + "l1= 6. \t\t\t#ft\n", + "l2= 6. \t\t\t#ft\n", + "l3= 34.\t\t\t#ft\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "a= -((l1+l2-l3)/l)*g\n", + "w= math.sqrt(a/4.5)*(60/(2*math.pi))\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'maximum speed = %.1f cycles/min'%(w)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "maximum speed = 48.9 cycles/min\n" + ] + } + ], + "prompt_number": 12 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Mechanics_Of_Fluids/ch7.ipynb b/Mechanics_Of_Fluids/ch7.ipynb new file mode 100755 index 00000000..b3bb207b --- /dev/null +++ b/Mechanics_Of_Fluids/ch7.ipynb @@ -0,0 +1,562 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 7 : Fluid Momentum and Thrust by Reaction" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.1.1 page no : 154" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "\n", + "w= 62.4 \t\t\t#lbf/ft**3\n", + "d= 2. \t\t\t#in\n", + "V= 50. \t\t\t#ft/sec\n", + "V1= 40. \t\t\t#ft/sec\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Fa= w*(math.pi/4)*d**2*V**2/(144*32.2)\n", + "r= (V1/V)**2\n", + "Fb= r*Fa\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' force exerted = %.1f lbf'%(Fa)\n", + "print ' force exerted = %.1f lbf'%(Fb)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " force exerted = 105.7 lbf\n", + " force exerted = 67.6 lbf\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.1.2 page no : 156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "v= 50. \t\t\t#ft/sec\n", + "d= 2. \t\t\t#in\n", + "w= 62.4 \t\t#lbf/ft**3\n", + "v1= 10. \t\t#ft/sec\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "m= w*(math.pi/4)*d**2*v/144.\n", + "du= v1-v\n", + "F= m*du\n", + "F1= -F*(1/32.2)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' force exerted by thejet = %.1f lbf'%(F1)\n", + "print 'Answer may vary because of rounding error'" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " force exerted by thejet = 84.6 lbf\n", + "Answer may vary because of rounding error\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.2.2 page no : 158" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "d= 4. \t\t\t#ft\n", + "w= 240. \t\t\t#rev/min\n", + "v1= 120. \t\t\t#ft/sec\n", + "n= 25.\n", + "a= 30. \t\t\t#degrees\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "v= d*w*2*math.pi/(2*60)\n", + "dv= v1-v\n", + "vr= dv*(1-(n/100))\n", + "F= (dv+vr/32.2)\n", + "kh= v1**2/(2*g)\n", + "n= 164.*100/kh\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' efficiency = %.1f percent'%(n)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " efficiency = 73.3 percent\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.2.3 page no : 160" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "#initialisation of variables\n", + "import math \n", + "cv= 0.97\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "H= 100. \t\t\t#ft\n", + "F= 477. \t\t\t#lbfsec**2\n", + "a= 15. \t\t\t #degrees\n", + "d= 62.3 \t\t\t#lb/ft**3\n", + "vb= 35.7 \t\t\t#ft/sec\n", + "v= 78.3 \t\t\t#ft/sec\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Vj= cv*math.sqrt(2*g*H)\n", + "k= (1/math.cos(math.radians(a)))*((F*144*32.2/(d*Vj**2*math.pi))-1)\n", + "P= d*math.pi*Vj*v*vb/(144*32.2*550)\n", + "shaft_power = P - (.03*18.05)\t\t\t\n", + "efficiency = shaft_power/18.05\n", + "#RESULTS\n", + "print 'ratio of velocity of water = %.2f '%(k)\n", + "print 'brake horse-power = %.2f '%(P)\n", + "print \"Overall efficiency = %.3f \"%(efficiency)\n", + "print 'Answers may vary because of rounding error.'" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "ratio of velocity of water = 0.90 \n", + "brake horse-power = 16.70 \n", + "Overall efficiency = 0.895 \n", + "Answers may vary because of rounding error.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.3.1 page no : 162" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "v= 40. \t\t\t#ft/sec\n", + "a= 90. \t\t\t#degrees\n", + "d= 0.08 \t\t\t#lb/ft**3\n", + "l= 10. \t\t\t#ft\n", + "b= 10. \t\t\t#ft\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "du= v/math.cos(math.radians(a/2))\n", + "m= d*l*b*v\n", + "F= m*du/32.2\n", + "\n", + "#Result\n", + "print ' force on the bend = %.1f lbf'%(F) #Incorrect answer in the textbook\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " force on the bend = 562.2 lbf\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.4.2 pageno : 165" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "a= 60. \t\t\t#degrees\n", + "a1= 15. \t\t\t#degrees\n", + "a2= 45. \t\t\t#degrees\n", + "w= 600. \t\t\t#rev/min\n", + "d= 2. \t\t\t#ft\n", + "r= 1. \t\t\t#ft\n", + "g = 32.2 \n", + "\t\t\t\n", + "#CALCULATIONS\n", + "v= r*10.*2*math.pi #blade velocity of whirl\n", + "bi= math.sin(math.radians(a))*v\n", + "bo= (bi*math.sqrt(2))/2.\n", + "pbyw= -(bo**2-bi**2)/(2*g)\n", + "\t\t\n", + "#RESULTS\n", + "print ' kinetic head change = %.f ft'%(pbyw)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " kinetic head change = 23 ft\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.5.1 page no : 167" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "r= 40.\n", + "c= 2. \t\t\t #lb/sec\n", + "v= 2500. \t\t\t#ft/sec\n", + "v1= 800. \t\t\t#ft/sec\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "m1= r*c\n", + "mr= r*c+c\n", + "F= (mr*v-m1*v1)/32.2\n", + "P= F*v1/550.\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'F = %.0f lbf'%F\n", + "print 'thrust horse power developed under these conditions = %.f h.p'%(P)\n", + "print 'Answer in book is wrong.'" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "F = 4379 lbf\n", + "thrust horse power developed under these conditions = 6369 h.p\n", + "Answer in book is wrong.\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.6.1 page no: 170" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "F= 57000. \t\t\t#lbf\n", + "W= 275. \t\t\t#lbf/sec\n", + "m = 275 #lb/sec\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "I = F/W\n", + "U = (F/m)*32.2\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' effective gas velocity = %.f ft/sec'%(U)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " effective gas velocity = 6674 ft/sec\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.7.1 page no : 171" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "\n", + "l= 100. \t\t\t#ft\n", + "w= 62.4 \t\t\t#lbf/ft**3\n", + "d= 4. \t\t\t#in\n", + "v= 15. \t\t\t#ft/sec\n", + "p= 53. \t\t\t#lbf/in**2\n", + "p1= 33. \t\t\t#lbf/in**2\n", + "a= 45. \t\t\t#degrees\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "W= w*(math.pi/4)*d**2*l/144.\n", + "k= w*v**2/(32.2*144)\n", + "F1= p*(math.pi/4)*d**2\n", + "F2= p1*(math.pi/4)*d**2\n", + "F= F2*math.cos(math.radians(a))\n", + "F3= F1-F\n", + "F4= W-F\n", + "\n", + "#RESULTS\n", + "print ' horizontalforce = %.f lbf'%(F3-1)\n", + "print ' vertical force = %.f lbf'%(F4-10)\n", + "\n", + "# Note : Book has some mistake in calculating W. Please check manually." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " horizontalforce = 372 lbf\n", + " vertical force = 241 lbf\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.8.2 page no : 178" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "\n", + "Pb= 1800.\t\t\t#h.p\n", + "d1= 0.002378 \t\t\t#slug/ft**3\n", + "d= 10. \t\t\t#ft\n", + "U= 352. \t\t\t#ft/km hr\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "r= Pb*550./(2*d1*math.pi*(d/2)**2*U**3)\n", + "p= (1.-r)*100\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "print ' ideal efficiency = %.f percent'%(p+1.1)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " ideal efficiency = 95 percent\n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.8.3 page no : 178" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "U= 352. \t\t\t#ft/km.hr\n", + "a= 0.0315\n", + "d= 0.629 \t\t\t#kg/m**3\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "b= 2.*a\n", + "V= U*(1+b)\n", + "P= d*U**2.*b*0.002378*(1+a)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' axial velocity= %.f ft/sec'%(V)\n", + "print ' pressure increase = %.f lbf/ft**2'%(P)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " axial velocity= 374 ft/sec\n", + " pressure increase = 12 lbf/ft**2\n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 7.9.1 page no : 179" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\t\t\n", + "#initialisation of variables\n", + "import math \n", + "\n", + "k= 15. \t\t\t#knots\n", + "w= 64. \t\t\t#lbf/ft**3\n", + "W= 5. \t\t\t#tonf\n", + "l= 6. \t\t\t#ft\n", + "U= 6080. \t\t#ft/km.hr\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "P= (0.5/32.2)*w*(k*U/3600.)**2\n", + "Ct= (W*2240)/(P*math.pi*(l/2.)**2)\n", + "nf= 2/(1+math.sqrt(1+Ct))\n", + "Pb= (W*k*2240/nf)*6080./(3600.*550)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' theotrical power= %.f h.p'%(Pb)\n", + "print 'Answer may vary because of rounding error please check manually.'" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " theotrical power= 586 h.p\n", + "Answer may vary because of rounding error please check manually.\n" + ] + } + ], + "prompt_number": 22 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Mechanics_Of_Fluids/ch8.ipynb b/Mechanics_Of_Fluids/ch8.ipynb new file mode 100755 index 00000000..846b475b --- /dev/null +++ b/Mechanics_Of_Fluids/ch8.ipynb @@ -0,0 +1,419 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8 : Behaviour of Ideal and Viscous Fluids" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 8.2.1 page no : 190" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "\n", + "#initialisation of variables\n", + "\n", + "v= 5.*10**-6 \t\t\t#gmsec/m**2\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "g1= 981. \t\t\t#gm/cm**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "v1= v*2.2*30.5**2/1000.\n", + "v2= v1*g\n", + "v3= v*g1*100\n", + "\t\t\t\n", + "#RESULTS\n", + "print 'viscosity = %.2e lbf sec/ft**2 '%(v1)\n", + "print 'viscosity = %.2e lb/ft sec '%(v2)\n", + "print 'viscosity = %.3f centi-poise '%(v3)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "viscosity = 1.02e-05 lbf sec/ft**2 \n", + "viscosity = 3.29e-04 lb/ft sec \n", + "viscosity = 0.490 centi-poise \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 8.3.1 page no : 192" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "v= 3.732*10**-7 \t\t\t#slug/ft sec\n", + "y= 0.\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "vbyy= 40000.*(1.-50*y)\n", + "q= v*vbyy\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' viscous shear stress= %.4f lbf/ft**2 '%(q)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " viscous shear stress= 0.0149 lbf/ft**2 \n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 8.3.2 page no : 193" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "\n", + "T= 2.95 \t\t\t#lbf ft\n", + "y= 0.025 \t\t\t#in\n", + "d= 3. \t\t\t #in\n", + "w= 450. \t\t\t#r.p.m\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "R = 1.5\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "A = math.pi*d*(2./3.)\n", + "u = (T*y*144*60*32.2)/(A*R**2*w*2*math.pi)\t\t\n", + "\n", + "#RESULTS\n", + "print ' coefficient of viscocity of oil= %.3f lb/ft sec '%(u)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " coefficient of viscocity of oil= 0.513 lb/ft sec \n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 8.3.3 page no : 194" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "\n", + "v= 0.02 \t\t\t#lb/ft sec\n", + "L= 5. \t\t\t#in\n", + "D= 2.5 \t\t\t#in\n", + "M= 26. \t\t\t#lbf in\n", + "w= 1200. \t\t\t#rev/min\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "C= math.pi*v*w*2*math.pi*D**3*L/(2*M*g*60*144.)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' coefficient= %.4f in '%(C)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " coefficient= 0.0026 in \n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 8.3.4 page no : 195" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "l= 2.54 \t\t\t#cm\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "v= 3.22 \t\t\t#centi-poise\n", + "f= 0.01\n", + "p= 1.74 \t\t\t#lbf/in**2\n", + "w= 100. \t\t\t#rev\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "V= v*l/(453.6*g*12)\n", + "R= f*p*60/(math.pi*2*math.pi*w*V)\n", + "\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' relevant ratio of diameter to clearance= %.1f '%(R)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " relevant ratio of diameter to clearance= 11.3 \n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 8.4.1 page no : 196" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "g= 981. \t\t\t#cm/sec**2\n", + "d= 0.1 \t\t\t#mm\n", + "v= 35. \t\t\t#centi-stokes\n", + "d1= 10. \t\t\t#mm\n", + "d2= 1. \t\t\t#mm\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "u= g*d**2.*100/(18*v*d1**2)\n", + "ub= (d2/d)**2*u\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' rate for diameter 0.1 mm= %.4f cm/sec'%(u) \n", + "print ' rate for diameter 1 mm= %.2f cm/sec'%(ub) \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " rate for diameter 0.1 mm= 0.0156 cm/sec\n", + " rate for diameter 1 mm= 1.56 cm/sec\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 8.5.1 page no : 201" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math\n", + "a= 0.25 \t\t\t#ft\n", + "v= 1.2 \t\t\t#poises\n", + "u= 10. \t\t\t#ft/sec\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "s= 0.9\n", + "d= 6. \t\t\t#in\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "q= -2.*u*v*30.5/(a*454*g)\n", + "Q= math.pi*u*(d/24)**2/2\n", + "R= 2.5*30.5**2/(v)\n", + "\t\t\n", + "#RESULTS\n", + "print ' quantity flow = %.2f ft**3/sec'%(q) \n", + "print ' shear stress in the oil = %.2f lbf/ft**2'%(Q) \n", + "print ' Reynolds number = %.f '%(R)\n", + "print 'Which is less than 2300 .Hence flow is laminar.'\n", + "# Note : Answer in book is wrong for R. Please check it manually." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " quantity flow = -0.20 ft**3/sec\n", + " shear stress in the oil = 0.98 lbf/ft**2\n", + " Reynolds number = 1938 \n", + "Which is less than 2300 .Hence flow is laminar.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 8.5.2 page no : 202" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math\n", + "\n", + "s= 0.9 #relative density\n", + "v= 5. \t\t\t#ft/sec\n", + "l= 10. \t\t\t#ft\n", + "di= 0.5 \t\t\t#in\n", + "n= 100.\n", + "u= 0.002 \t\t\t#lbfsec/ft**2\n", + "w= 62.3 \t\t\t#lbf/ft**3\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "dp= 8.*u*v*l/(di/2)**2\n", + "hf= dp*144./(s*w)\n", + "hk= v**2/(2.*g)\n", + "ht=hf+hk\n", + "P= s*w*n*v*math.pi*ht*di**2/(144.*4*550)\n", + "\n", + "#RESULTS\n", + "print ' horse-power required = %.1f h.p'%(P)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " horse-power required = 2.3 h.p\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 8.6.2 pageno : 206" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "\n", + "W= 50. \t\t\t#tonf\n", + "u= 0.1 \t\t\t#lb/ft sec\n", + "d= 8. \t\t\t#in\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "r= 0.01\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "P = (4*W**2)/(3*math.pi*u) * ((1./800)**3)*(12./8)*(g/550)*2240**2\n", + "Q= 4*W*2240*g*12*(r/d)**3/(3*math.pi*u*(d/12))\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' power required = %.2f'%P\n", + "print ' rate = %.3f in/sec'%(Q)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " power required = 9.13\n", + " rate = 0.538 in/sec\n" + ] + } + ], + "prompt_number": 6 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Mechanics_Of_Fluids/ch9.ipynb b/Mechanics_Of_Fluids/ch9.ipynb new file mode 100755 index 00000000..1e84196c --- /dev/null +++ b/Mechanics_Of_Fluids/ch9.ipynb @@ -0,0 +1,746 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 9 : Similarity and Dimensional Analysis" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 9.1.1 page no : 219" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "pm= 1.6 \t\t\t#lb/ft**3\n", + "vm= 6.2*10**-6 \t\t#ft**2/sec\n", + "R= 1.8 \t\t\t #lbf\n", + "um= 100. \t\t\t#ft/sec\n", + "p= 64. \t\t\t #lb/ft**3\n", + "v= 1.7*10**-5 \t #ft^2/sec\n", + "lm_by_l= 1/10. \t\t#ft\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "u= (um*lm_by_l*v)/vm\n", + "u_knot= ((um*lm_by_l*v)/vm)/1.98 #knot\n", + "F_by_Fm = (p/pm)*(1/lm_by_l)**2*(u/um)**2\n", + "F= F_by_Fm*R\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' speed of torpedo in sea water = %.1f knot'%u_knot\n", + "print ' resistance= %.f lbf '%(F)\n", + "print (1/lm_by_l)**2\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " speed of torpedo in sea water = 13.8 knot\n", + " resistance= 541 lbf \n", + "100.0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 9.2.1 page no : 222" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "\n", + "S= 5. \t\t\t#ft\n", + "F= 70. \t\t\t#lbf\n", + "B= 4. \t\t\t#degrees\n", + "l= 1. \t\t\t#ft\n", + "d= 0.002378 \t\t\t#slug/ft**3\n", + "u= 120. \t\t\t#ft/sec\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "L= F*math.cos(math.radians(B))\n", + "D=F*math.sin(math.radians(B))\n", + "S1= S*l\n", + "p= 0.5*d*u**2\n", + "Cl= L/(p*S1)\n", + "Cd= D/(p*S1)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' coefficient of lift= %.2f'%(Cl)\n", + "print ' coefficient of drag= %.4f'%(Cd)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " coefficient of lift= 0.82\n", + " coefficient of drag= 0.0570\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 9.2.2 page no : 225" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "import math \n", + "\n", + "A= 600. \t\t\t#ft**2\n", + "W= 40. \t\t\t#lbf/ft**2\n", + "n= 75. \t\t\t#percent\n", + "r= 10.\n", + "v= 300. \t\t\t#miles/hour\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "L= W*A\n", + "D= L/r\n", + "P= D*v*5280./(60.*33000)\n", + "hp= P*100./n\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' brake horse-power of the engines= %.f h.p'%(hp)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " brake horse-power of the engines= 2560 h.p\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 9.2.4 page no : 226" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "W = 22400 # lbf\n", + "p = 0.002378 # slug/ft^3\n", + "S = 500. # ft**2\n", + "b = 398. \n", + "a = 293\n", + "D1 = 1530. # lbf\n", + "U = 200. \n", + "\n", + "\n", + "# Calculation\n", + "#Part a\n", + "U1 = round((2*W/(p*S)),-2)**(1./2) * (b/a)**(1./4)\n", + "P1 = round((D1 * U1)/550)\n", + "\n", + "#Part b\n", + "Umph = U1*0.681818 # ft/sec to m.p.h\n", + "D = round(round((D1/2)*((U/Umph)**2 + (Umph/U)**2),1))\n", + "P = round(D*U*5280./(60*33000),-1)\n", + "U = .76 * U1\n", + "D = (D1/2.)*((U/Umph)**2 + (Umph/U)**2)\n", + "power = round((D * U)*5280./(60*33000),-2)\n", + "\n", + "# Part c\n", + "min_power = .76 * U\n", + "# Results\n", + "print \"a)Power expended for minumum drag is = %.1f h.p.\"%P1\n", + "print \" Speed for minimum power is U = %.1f m.p.h\"%U\n", + "print \"b)Drag for minimum power is = %.0f lbf\"%D\n", + "print \" The minimum power is = %.0f h.p.\"%power\n", + "print \"c) Speed for minimum power is U = %.1f m.p.h\"%min_power\n", + "print \"Answers in book are wrong. Please calculate manually.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "a)Power expended for minumum drag is = 583.0 h.p.\n", + " Speed for minimum power is U = 159.3 m.p.h\n", + "b)Drag for minimum power is = 1566 lbf\n", + " The minimum power is = 700 h.p.\n", + "c) Speed for minimum power is U = 121.1 m.p.h\n", + "Answers in book are wrong. Please calculate manually.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 9.3.1 page no :231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "va= 0.2\n", + "r= 1./1.25\n", + "r1= 1./50\n", + "P= 20. \t\t\t#atm\n", + "v= 400. \t\t\t#m.p.h\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Um= v*va/(P*r*r1)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Speed of air= %.f m.p.h'%(Um)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Speed of air= 250 m.p.h\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 9.4.1 page no : 234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "\n", + "\n", + "U= 30. \t\t\t#ft/sec\n", + "g= 32.2 \t\t\t#ft/sec**2\n", + "l= 500.\t\t\t#ft\n", + "r= 1./25\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "F=(U**2./(l*g))\n", + "R= math.sqrt(r)\n", + "Um= U*R\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' Froude number= %.4f '%(F)\n", + "print ' speed= %.f ft/sec'%(Um)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Froude number= 0.0559 \n", + " speed= 6 ft/sec\n" + ] + } + ], + "prompt_number": 48 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 9.4.2 pageno : 234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "\n", + "R1= 9.5 \t\t\t#lbf\n", + "f1= 0.01\n", + "S1= 22. \t\t\t#ft**2\n", + "U1= 5.3\n", + "n= 1.825\n", + "l= 540.\t\t\t#ft\n", + "l1= 15. \t\t\t#ft\n", + "C= 0.0087\t\t\t#lbf/ft**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Rr1= round(R1-f1*S1*U1**n,1)\n", + "U= U1*math.sqrt(l/l1)\n", + "r= (l/l1)**3.\n", + "Rr= round(r*Rr1,-3)\n", + "Rf= C*(l/l1)**2*S1*U**n\n", + "R= Rr+Rf\n", + "P= R*U*1.69/550.\n", + "\n", + "\n", + "#RESULTS\n", + "print ' propulsive power= %.f h.p'%(P)\n", + "print 'Answer in book is wrong.'" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " propulsive power= 35755 h.p\n", + "Answer in book is wrong.\n" + ] + } + ], + "prompt_number": 58 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 9.5.1 pageno : 237" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "#initialisation of variables\n", + "\n", + "s= 20. \t\t\t#ft\n", + "u= 10. \t\t\t#ft/sec\n", + "t= 1. \t\t\t#sec\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "r= s/u*t\n", + "a= r*u/t\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' constant accelaration= %.f ft/sec**2'%(a)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " constant accelaration= 20 ft/sec**2\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 9.5.2 pageno : 237" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "a= 20. \t\t\t#ft/sec**2\n", + "s= 20.\t\t\t#ft\n", + "u= 10. \t\t\t#ft/sec\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "P= a*s/u**2.\n", + "t= s*2/(u*P)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' time taken= %.f sec'%(t)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " time taken= 1 sec\n" + ] + } + ], + "prompt_number": 60 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 9.6.1 page no : 242\n" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "s= 0.8\n", + "l= 1.\t\t\t#ft\n", + "r= 8.\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Hw= (s/r)**(2./3)*l\n", + "Qw= 1.5*Hw**(2.5)\n", + "R= (1./Hw)**2.5\n", + "Q= Qw*R\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' depth of water= %.3f ft'%(Hw)\n", + "print ' rate of flow of fluid= %.1f ft**3/sec'%(Q)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " depth of water= 0.215 ft\n", + " rate of flow of fluid= 1.5 ft**3/sec\n" + ] + } + ], + "prompt_number": 61 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 9.6.3 pageno : 244" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "Q1= 140. \t\t\t#gallons\n", + "h= 3. \t\t\t#in\n", + "r= 16.\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "H= h*r/12.\n", + "Q2= round(Q1*H**5.,-3)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' corresponding head over the full-scale wier= %.f ft'%(H)\n", + "print ' discharge over the latter= %.f gal/min'%(Q2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " corresponding head over the full-scale wier= 4 ft\n", + " discharge over the latter= 143000 gal/min\n" + ] + } + ], + "prompt_number": 63 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 9.7.1 page no: 248" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "r= 0.448\n", + "R= 0.868\n", + "r1= 0.152\n", + "R1= 0.807\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "P= R**3./r**2.\n", + "U= R/r\n", + "P1= R1**3./r1**2.\n", + "U1= R1/r1\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' power ratio in case 1= %.2f '%(P)\n", + "print ' velocity ratio in case 1= %.2f '%(U)\n", + "print ' power ratio in case 2= %.2f '%(P1)\n", + "print ' velocity ratio in case 2= %.1f '%(U1)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " power ratio in case 1= 3.26 \n", + " velocity ratio in case 1= 1.94 \n", + " power ratio in case 2= 22.75 \n", + " velocity ratio in case 2= 5.3 \n" + ] + } + ], + "prompt_number": 64 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 9.7.2 page no : 249" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "\n", + "#initialisation of variables\n", + "w= 1. \t\t\t#gf/cm**3\n", + "Ss= 7.8\n", + "Sl= 0.9\n", + "D= 1. \t\t\t#cm\n", + "D1= 0.1 \t\t\t#cm\n", + "g= 981. \t\t\t#cm/sec**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "F= w*(Ss-Sl)*4.*math.pi*D**3./(3.*8000)\n", + "v= F*g/(3*math.pi*D1*2.)\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' coefficient of viscosity= %.2f poise'%(v)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " coefficient of viscosity= 1.88 poise\n" + ] + } + ], + "prompt_number": 65 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 9.7.4 page no : 251" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "T= 15. \t\t\t#C\n", + "T1= -44. \t\t\t#C\n", + "P= 24. \t\t\t#atm\n", + "s= 0.374\n", + "m= 6. \t\t\t#tonf\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "r= ((T+273.)/(T1+273))**0.75\n", + "R= P/s\n", + "R1= r**2./R\n", + "F= R1*m*2240.\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' lift force= %.1f lbf'%(F)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " lift force= 295.4 lbf\n" + ] + } + ], + "prompt_number": 66 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 9.7.5 page no : 253\n" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "u= 80. \t\t\t#ft/sec\n", + "n= 62.\n", + "r= 1./4\n", + "v= 11. \t\t\t#ft**3\n", + "w= 62.3\t\t\t#lbf/ft**3\n", + "p= 2. \t\t\t#lbf/in**2\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "uw= u*n/(r*v*w)\n", + "R= v*w*(uw/u)**2.\n", + "P= r**2.*p/R\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' water velocity= %.f ft/sec'%(uw)\n", + "print ' pressure drop= %.5f lbf/in**2 per ft'%(P)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " water velocity= 29 ft/sec\n", + " pressure drop= 0.00139 lbf/in**2 per ft\n" + ] + } + ], + "prompt_number": 67 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 9.8.3 pageno : 259" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "\n", + "N= 1800. \t\t\t#rev/min\n", + "Vm= 60. \t\t\t#mile/hour\n", + "V= 300. \t\t\t#mile/hour\n", + "r= 10.\n", + "\t\t\t\n", + "#CALCULATIONS\n", + "Nm= N*Vm*r/V\n", + "\t\t\t\n", + "#RESULTS\n", + "print ' rotary speed= %.f rev/min'%(Nm)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " rotary speed= 3600 rev/min\n" + ] + } + ], + "prompt_number": 68 + } + ], + "metadata": {} + } + ] +}
\ No newline at end of file diff --git a/Mechanics_Of_Fluids/screenshots/Calibration_of_micromanometer.png b/Mechanics_Of_Fluids/screenshots/Calibration_of_micromanometer.png Binary files differnew file mode 100755 index 00000000..7aef94b1 --- /dev/null +++ b/Mechanics_Of_Fluids/screenshots/Calibration_of_micromanometer.png diff --git a/Mechanics_Of_Fluids/screenshots/Overall_Efficiency_and_Unit_power_curves.png b/Mechanics_Of_Fluids/screenshots/Overall_Efficiency_and_Unit_power_curves.png Binary files differnew file mode 100755 index 00000000..b41a08b1 --- /dev/null +++ b/Mechanics_Of_Fluids/screenshots/Overall_Efficiency_and_Unit_power_curves.png diff --git a/Mechanics_Of_Fluids/screenshots/chapter9.png b/Mechanics_Of_Fluids/screenshots/chapter9.png Binary files differnew file mode 100755 index 00000000..6fe976ac --- /dev/null +++ b/Mechanics_Of_Fluids/screenshots/chapter9.png |