summaryrefslogtreecommitdiff
path: root/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch8.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch8.ipynb')
-rw-r--r--Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch8.ipynb947
1 files changed, 0 insertions, 947 deletions
diff --git a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch8.ipynb b/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch8.ipynb
deleted file mode 100644
index a4d4d774..00000000
--- a/Engineering_Thermodynamics:_A_Computer_Approach_(SI_Units_Version)/ch8.ipynb
+++ /dev/null
@@ -1,947 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:79346296b970ba1771cf99da135ed51f1d98b24ac99e0b8758fa3cab63c95d45"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "n= [44] # n holds the int 44\n",
- "print \"int n=44; // n holds the int 44:\\n\";\n",
- "print \"\\t\\t n = \" , n \n",
- "print \"\\t\\t &n = \" , hex(id(n))\n",
- "pn = n \n",
- "print \"int* pn=&n; // pn holds the address of n:\\n\";\n",
- "print \"\\t\\t n = \" , n \n",
- "print \"\\t\\t &n = \" , hex(id(n))\n",
- "print \"\\t\\t pn = \" , hex(id(pn)) \n",
- "print \"\\t\\t &pn = \" , hex(id(hex(id(pn))))\n",
- "print \"\\t\\t *pn = \" , pn\n",
- "\n",
- "pn[0] = 77 # changes the value of n to 77\n",
- "print \"*pn = 77; // changes the value of n to 77:\\n\";\n",
- "print \"\\t\\t n = \" , n \n",
- "print \"\\t\\t &n = \" , hex(id(n))\n",
- "print \"\\t\\t pn = \" , hex(id(pn)) \n",
- "print \"\\t\\t &pn = \" , hex(id(hex(id(pn))))\n",
- "print \"\\t\\t *pn = \" , pn\n",
- "\n",
- "q = n \n",
- "print \"int* q=&n; // q also holds the address of n:\\n\";\n",
- "print \"\\t\\t n = \" , n \n",
- "print \"\\t\\t &n = \" , hex(id(n))\n",
- "print \"\\t\\t pn = \" , hex(id(pn)) \n",
- "print \"\\t\\t &pn = \" , hex(id(hex(id(pn))))\n",
- "print \"\\t\\t *pn = \" , pn\n",
- "print \"\\t\\t q = \" , hex(id(q))\n",
- "print \"\\t\\t &q = \" , hex(id(hex(id(hex(id(pn))))))\n",
- "print \"\\t\\t *q = \" , q \n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "int n=44; // n holds the int 44:\n",
- "\n",
- "\t\t n = [44]\n",
- "\t\t &n = 0x9bfb92c\n",
- "int* pn=&n; // pn holds the address of n:\n",
- "\n",
- "\t\t n = [44]\n",
- "\t\t &n = 0x9bfb92c\n",
- "\t\t pn = 0x9bfb92c\n",
- "\t\t &pn = 0x9bf5aa0\n",
- "\t\t *pn = [44]\n",
- "*pn = 77; // changes the value of n to 77:\n",
- "\n",
- "\t\t n = [77]\n",
- "\t\t &n = 0x9bfb92c\n",
- "\t\t pn = 0x9bfb92c\n",
- "\t\t &pn = 0x9c6a760\n",
- "\t\t *pn = [77]\n",
- "int* q=&n; // q also holds the address of n:\n",
- "\n",
- "\t\t n = [77]\n",
- "\t\t &n = 0x9bfb92c\n",
- "\t\t pn = 0x9bfb92c\n",
- "\t\t &pn = 0x9bf5c80\n",
- "\t\t *pn = [77]\n",
- "\t\t q = 0x9bfb92c\n",
- "\t\t &q = 0x9c6a760\n",
- "\t\t *q = [77]\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "s = \"ABCD\"\n",
- "for i in range(4):\n",
- " print \"s[\" , i , \"] = '\" , s[i] , \"'\\n\";\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "s[ 0 ] = ' A '\n",
- "\n",
- "s[ 1 ] = ' B '\n",
- "\n",
- "s[ 2 ] = ' C '\n",
- "\n",
- "s[ 3 ] = ' D '\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "while True:\n",
- " word = raw_input()\n",
- " if len(word) < 2:\n",
- " break\n",
- " l = word.split(' ')\n",
- " for i in l:\n",
- " print '\\t\"' , i , '\"'\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Today's date is March 12, 2000.\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\t\" Today's \"\n",
- "\t\" date \"\n",
- "\t\" is \"\n",
- "\t\" March \"\n",
- "\t\" 12, \"\n",
- "\t\" 2000. \"\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Tomorrow is Monday.\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\t\" Tomorrow \"\n",
- "\t\" is \"\n",
- "\t\" Monday. \"\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "while True:\n",
- " line = raw_input()\n",
- " if len(line) < 2:\n",
- " break\n",
- " print \"\\t[\" , line , \"]\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Once upon a midnight dreary, while I pondered, weak and weary,\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\t[ Once upon a midnight dreary, while I pondered, weak and weary, ]\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Over a many quaint and curious volume of forgotten lore,\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\t[ Over a many quaint and curious volume of forgotten lore, ]\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "\n",
- "while True:\n",
- " word = raw_input()\n",
- " if len(word) < 2:\n",
- " break\n",
- " l = word.split(',')\n",
- " for i in range(len(l)-1):\n",
- " print '\\t[' , l[i] , ']'\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Once upon a midnight dreary, while I pondered, weak and weary,\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\t[ Once upon a midnight dreary ]\n",
- "\t[ while I pondered ]\n",
- "\t[ weak and weary ]\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Over a many quaint and curious volume of forgotten lore,\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\t[ Over a many quaint and curious volume of forgotten lore ]\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "count = 0\n",
- "while True:\n",
- " a = raw_input()\n",
- " if len(a) < 1:\n",
- " break\n",
- " for ch in a:\n",
- " if (ch == 'e'): count+=1\n",
- " \n",
- "print count , \" e's were counted.\\n\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Once upon a midnight dreary, while I pondered, weak and weary,\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Over many a quaint and curious volume of forgotten lore,\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "11 e's were counted.\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "while True:\n",
- " a = raw_input()\n",
- " if len(a) < 1:\n",
- " break\n",
- " print a.title()\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Fourscore and seven years ago our fathers\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Fourscore And Seven Years Ago Our Fathers\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "brought forth upon this continent a new nation,\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Brought Forth Upon This Continent A New Nation,\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "a = raw_input()\n",
- "l = a.split(' ')\n",
- "nos = []\n",
- "for i in l:\n",
- " try:\n",
- " i = int(i)\n",
- " nos.append(i)\n",
- " except:\n",
- " continue\n",
- "m = nos[0]\n",
- "n = nos[1] \n",
- "print m , \" + \" , n , \" = \" , m+n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "what is 305 plus 9416 ?\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "305 + 9416 = 9721\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "name = []\n",
- "count=0\n",
- "\n",
- "print \"Enter at most 4 names with at most 19 characters:\\n\";\n",
- "while (True):\n",
- " n = raw_input()\n",
- " if len(n) < 1:\n",
- " break\n",
- " name.append(n)\n",
- " count += 1\n",
- " \n",
- "print \"The names are:\\n\"\n",
- "for i in range(count):\n",
- " print \"\\t\" , i , \". [\" , name[i] , \"]\" \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter at most 4 names with at most 19 characters:\n",
- "\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "George Washington\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "John Adams\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Thomas Jefferson\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The names are:\n",
- "\n",
- "\t0 . [ George Washington ]\n",
- "\t1 . [ John Adams ]\n",
- "\t2 . [ Thomas Jefferson ]\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "name = []\n",
- "count=0\n",
- "\n",
- "print \"Enter at most 4 names with at most 19 characters:\\n\";\n",
- "while (True):\n",
- " n = raw_input()\n",
- " if len(n) < 1:\n",
- " break\n",
- " name.append(n)\n",
- " count += 1\n",
- " \n",
- "print \"The names are:\\n\"\n",
- "for i in range(count):\n",
- " print \"\\t\" , i , \". [\" , name[i] , \"]\" "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter at most 4 names with at most 19 characters:\n",
- "\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "George Washington\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "John Adams\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Thomas Jefferson\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The names are:\n",
- "\n",
- "\t0 . [ George Washington ]\n",
- "\t1 . [ John Adams ]\n",
- "\t2 . [ Thomas Jefferson ]\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "name = [ \"George Washington\", \"John Adams\", \"Thomas Jefferson\"]\n",
- "print \"The names are:\\n\"\n",
- "for i in range(3):\n",
- " print \"\\t\" , i , \". [\" , name[i] , \"]\"\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The names are:\n",
- "\n",
- "\t0 . [ George Washington ]\n",
- "\t1 . [ John Adams ]\n",
- "\t2 . [ Thomas Jefferson ]\n"
- ]
- }
- ],
- "prompt_number": 14
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "s = \"ABCDEFG\"\n",
- "print \"len(\" , s , \") = \" , len(s) \n",
- "print \"len(\\\"\\\") = \" , len(\"\")\n",
- "print \"Enter string: \"\n",
- "b = raw_input()\n",
- "print \"len(\" , b , \") = \" , len(b)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "len( ABCDEFG ) = 7\n",
- "len(\"\") = 0\n",
- "Enter string: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "hello how are you !!!\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "len( hello how are you !!! ) = 21\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "s = \"The Mississippi is a long river.\"\n",
- "print 's = \"' , s , '\"'\n",
- "p = s.find(' ')\n",
- "print \"find(s, ' ') points to s[\" , p , \"].\"\n",
- "p = s.find('s')\n",
- "print \"find(s, 's') points to s[\" , p , \"].\"\n",
- "p = s.rfind('s')\n",
- "print \"reverse find(s, 's') points to s[\" , p , \"].\"\n",
- "p = s.find(\"is\")\n",
- "print \"strstr(s, \\\"is\\\") points to s[\" , p , \"].\"\n",
- "p = s.find(\"isi\")\n",
- "if p== -1:\n",
- " print 's.find(\"isi\") returns NULL'\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "s = \" The Mississippi is a long river. \"\n",
- "find(s, ' ') points to s[ 3 ].\n",
- "find(s, 's') points to s[ 6 ].\n",
- "reverse find(s, 's') points to s[ 17 ].\n",
- "strstr(s, \"is\") points to s[ 5 ].\n",
- "s.find(\"isi\") returns NULL\n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "s1 = \"ABCDEFG\"\n",
- "s2 = \"XYZ\" \n",
- "print \"Before strcpy(s1,s2):\\n\" \n",
- "print \"\\ts1 = [\" , s1 , \"], length = \" , len(s1) \n",
- "print \"\\ts2 = [\" , s2 , \"], length = \" , len(s2) \n",
- "s1 = s2\n",
- "print \"After strcpy(s1,s2):\\n\" \n",
- "print \"\\ts1 = [\" , s1 , \"], length = \" , len(s1) \n",
- "print \"\\ts2 = [\" , s2 , \"], length = \" , len(s2) \n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Before strcpy(s1,s2):\n",
- "\n",
- "\ts1 = [ ABCDEFG ], length = 7\n",
- "\ts2 = [ XYZ ], length = 3\n",
- "After strcpy(s1,s2):\n",
- "\n",
- "\ts1 = [ XYZ ], length = 3\n",
- "\ts2 = [ XYZ ], length = 3\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "s1 = \"ABCDEFG\"\n",
- "s2 = \"XYZ\" \n",
- "print \"Before strcpy(s1,s2,2):\\n\" \n",
- "print \"\\ts1 = [\" , s1 , \"], length = \" , len(s1) \n",
- "print \"\\ts2 = [\" , s2 , \"], length = \" , len(s2) \n",
- "s1 = s2[:2] + s1[2:]\n",
- "print \"After strcpy(s1,s2,2):\\n\" \n",
- "print \"\\ts1 = [\" , s1 , \"], length = \" , len(s1) \n",
- "print \"\\ts2 = [\" , s2 , \"], length = \" , len(s2) \n",
- "\n",
- "\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Before strcpy(s1,s2,2):\n",
- "\n",
- "\ts1 = [ ABCDEFG ], length = 7\n",
- "\ts2 = [ XYZ ], length = 3\n",
- "After strcpy(s1,s2,2):\n",
- "\n",
- "\ts1 = [ XYCDEFG ], length = 7\n",
- "\ts2 = [ XYZ ], length = 3\n"
- ]
- }
- ],
- "prompt_number": 18
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "s1 = \"ABCDEFG\"\n",
- "s2 = \"XYZ\" \n",
- "print \"Before string concatination :\\n\" \n",
- "print \"\\ts1 = [\" , s1 , \"], length = \" , len(s1) \n",
- "print \"\\ts2 = [\" , s2 , \"], length = \" , len(s2) \n",
- "s1 += s2\n",
- "print \"After string concatination :\" \n",
- "print \"\\ts1 = [\" , s1 , \"], length = \" , len(s1) \n",
- "print \"\\ts2 = [\" , s2 , \"], length = \" , len(s2) "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Before string concatination :\n",
- "\n",
- "\ts1 = [ ABCDEFG ], length = 7\n",
- "\ts2 = [ XYZ ], length = 3\n",
- "After string concatination :\n",
- "\ts1 = [ ABCDEFGXYZ ], length = 10\n",
- "\ts2 = [ XYZ ], length = 3\n"
- ]
- }
- ],
- "prompt_number": 19
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "s1 = \"ABCDEFG\"\n",
- "s2 = \"XYZ\" \n",
- "print \"Before string concatination :\\n\" \n",
- "print \"\\ts1 = [\" , s1 , \"], length = \" , len(s1) \n",
- "print \"\\ts2 = [\" , s2 , \"], length = \" , len(s2) \n",
- "s1 += s2[:2]\n",
- "print \"After string concatination :\" \n",
- "print \"\\ts1 = [\" , s1 , \"], length = \" , len(s1) \n",
- "print \"\\ts2 = [\" , s2 , \"], length = \" , len(s2) "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Before string concatination :\n",
- "\n",
- "\ts1 = [ ABCDEFG ], length = 7\n",
- "\ts2 = [ XYZ ], length = 3\n",
- "After string concatination :\n",
- "\ts1 = [ ABCDEFGXY ], length = 9\n",
- "\ts2 = [ XYZ ], length = 3\n"
- ]
- }
- ],
- "prompt_number": 20
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "\n",
- "s = \"Today's date is March 12, 2000.\"\n",
- "\n",
- "print \"The string is: [\" , s , \"] \\nIts tokens are: \"\n",
- "p = s.split(\" \")\n",
- "\n",
- "for i in p:\n",
- " print \"\\t[\" , i , \"] \"\n",
- "\n",
- "print \"Now the string is: [\" , p[0] , \"] \";\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The string is: [ Today's date is March 12, 2000. ] \n",
- "Its tokens are: \n",
- "\t[ Today's ] \n",
- "\t[ date ] \n",
- "\t[ is ] \n",
- "\t[ March ] \n",
- "\t[ 12, ] \n",
- "\t[ 2000. ] \n",
- "Now the string is: [ Today's ] \n"
- ]
- }
- ],
- "prompt_number": 21
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- " \n",
- "\n",
- "def strpbrk(s,s1):\n",
- " found = []\n",
- " for i in range(len(s1)):\n",
- " if s1[i] in s:\n",
- " index = s.find(s1[i])\n",
- " found.append(index)\n",
- " if found:\n",
- " return min(found)\n",
- " return None\n",
- " \n",
- "\n",
- "s = \"The Mississippi is a long river.\"\n",
- "print 's = \"' , s , '\"'\n",
- "p = strpbrk(s, \"nopqr\")\n",
- "print 'strpbrk(s, \"nopqr\") points to s[' , p , \"].\"\n",
- "p = strpbrk(s, \"NOPQR\")\n",
- "if (p == None):\n",
- " print 'strpbrk(s, \"NOPQR\") returns NULL.\\n'"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "s = \" The Mississippi is a long river. \"\n",
- "strpbrk(s, \"nopqr\") points to s[ 12 ].\n",
- "strpbrk(s, \"NOPQR\") returns NULL.\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 22
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file