"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"from ctypes import *\n",
"\n",
"#Variable declaration\n",
"str=\"This is a test\"\n",
"token =\"\"\n",
"i=0\n",
"\n",
"#Read a token at a time from the string\n",
"while iExample 6.6, Page Number: 115
"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"#Variable declaration\n",
"str=\"This is a test\"\n",
"i=0\n",
"\n",
"#Read a token at a time from the string\n",
"while iExample 6.7, Page Number: 115
"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"\n",
"import random\n",
"\n",
"fortunes=[\"Soon, you will come into some money.\",\n",
" \"A new love will enter your lifr. \",\n",
" \"You will live long and prosper.\",\n",
" \"Now is a good time to invest for the future.\",\n",
" \"A close friend will ask for a favour.\"]\n",
"\n",
"print \"To see your fortune, press a key: \"\n",
"\n",
"#Randomize the random number generator\n",
"chance=random.randint(0,100)\n",
"chance=chance%5\n",
"\n",
"#Result\n",
"print fortunes[chance]"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"To see your fortune, press a key: \n",
"A close friend will ask for a favour.\n"
]
}
],
"prompt_number": 6
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"