summaryrefslogtreecommitdiff
path: root/C_Programming_for_the_Absolute_Beginner
diff options
context:
space:
mode:
authorThomas Stephen Lee2015-09-04 22:04:10 +0530
committerThomas Stephen Lee2015-09-04 22:04:10 +0530
commit41f1f72e9502f5c3de6ca16b303803dfcf1df594 (patch)
treef4bf726a3e3ce5d7d9ee3781cbacfe3116115a2c /C_Programming_for_the_Absolute_Beginner
parent9c9779ba21b9bedde88e1e8216f9e3b4f8650b0e (diff)
downloadPython-Textbook-Companions-41f1f72e9502f5c3de6ca16b303803dfcf1df594.tar.gz
Python-Textbook-Companions-41f1f72e9502f5c3de6ca16b303803dfcf1df594.tar.bz2
Python-Textbook-Companions-41f1f72e9502f5c3de6ca16b303803dfcf1df594.zip
add/remove/update books
Diffstat (limited to 'C_Programming_for_the_Absolute_Beginner')
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/Chapter1.ipynb117
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/Chapter10.ipynb362
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/Chapter11.ipynb616
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/Chapter12.ipynb445
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/Chapter2.ipynb239
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/Chapter3.ipynb499
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/Chapter4.ipynb688
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/Chapter5.ipynb475
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/Chapter6.ipynb652
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/Chapter7.ipynb582
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/Chapter8.ipynb703
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/Chapter9.ipynb549
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/README.txt10
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/screenshots/1.pngbin15413 -> 0 bytes
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/screenshots/1_1.pngbin15413 -> 0 bytes
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/screenshots/2.pngbin9440 -> 0 bytes
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/screenshots/2_1.pngbin9440 -> 0 bytes
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/screenshots/3.pngbin32643 -> 0 bytes
-rwxr-xr-xC_Programming_for_the_Absolute_Beginner/screenshots/3_1.pngbin32643 -> 0 bytes
19 files changed, 0 insertions, 5937 deletions
diff --git a/C_Programming_for_the_Absolute_Beginner/Chapter1.ipynb b/C_Programming_for_the_Absolute_Beginner/Chapter1.ipynb
deleted file mode 100755
index 5c25ef5d..00000000
--- a/C_Programming_for_the_Absolute_Beginner/Chapter1.ipynb
+++ /dev/null
@@ -1,117 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:ed1073b28a905078eb23296522b8b59bf416e5275a011e43147248d1acd57f5a"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 1 GETTING STARTED WITH C PROGRAMMING"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 1.1, Page No. 6"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "print \"C you later\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "C you later\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 1.2, Page No. 18"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "print \"Chapter 1. Getting Started with C programming\"\n",
- "print \"This is an example of format bug.\"\n",
- "print \"The format issue can be corrected by using\"\n",
- "print \"the \\n and \\\\ escape sequnece\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Chapter 1. Getting Started with C programming\n",
- "This is an example of format bug.\n",
- "The format issue can be corrected by using\n",
- "the \n",
- " and \\ escape sequnece\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Exmaple 1.3, Page No. 18"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "print \"Chapter 1. Getting Started with C programming\"\n",
- "print \"This is an example of format bug.\"\n",
- "print \"The format issue can be corrected by using\"\n",
- "print \"the \\\\n and \\\\\\\\ escape sequnece\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Chapter 1. Getting Started with C programming\n",
- "This is an example of format bug.\n",
- "The format issue can be corrected by using\n",
- "the \\n and \\\\ escape sequnece\n"
- ]
- }
- ],
- "prompt_number": 4
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/C_Programming_for_the_Absolute_Beginner/Chapter10.ipynb b/C_Programming_for_the_Absolute_Beginner/Chapter10.ipynb
deleted file mode 100755
index c2e52854..00000000
--- a/C_Programming_for_the_Absolute_Beginner/Chapter10.ipynb
+++ /dev/null
@@ -1,362 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:af2735a34ebb2cb3c8a379aacf70cb46d8ee4a8ed09afacd9b5d0d21e0a0dd5a"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 10 : Dynamic Memory Allocation"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 10.1, Page No 229"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import sys\n",
- "class employee:\n",
- " def __init__(self,id1,name,salary):\n",
- " self.id1 = id1\n",
- " self.name = name\n",
- " self.salary = salary\n",
- "e = employee(10,\"abc\",12000.02)\n",
- "x = 1\n",
- "f = 1.1\n",
- "d = 1111.11\n",
- "c = 'C'\n",
- "print \"Sizo of integer : \" + str(sys.getsizeof(x)) + \"bytes \\n\"\n",
- "print \"Sizo of float : \" + str(sys.getsizeof(f)) + \"bytes \\n\"\n",
- "print \"Sizo of double : \" + str(sys.getsizeof(d)) + \"bytes \\n\"\n",
- "print \"Sizo of char : \" + str(sys.getsizeof(c)) + \"bytes \\n\"\n",
- "print \"Sizo of employee structure : \" + str(sys.getsizeof(e)) + \"bytes \\n\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Sizo of integer : 24bytes \n",
- "\n",
- "Sizo of float : 24bytes \n",
- "\n",
- "Sizo of double : 24bytes \n",
- "\n",
- "Sizo of char : 34bytes \n",
- "\n",
- "Sizo of employee structure : 64bytes \n",
- "\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 10.2, Page No 230"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import sys\n",
- "array = []\n",
- "\n",
- "print \"\\nSize of array: \" + str(sys.getsizeof(array)) + \"bytes\\n\"\n",
- "print \"Number of elements in array \"\n",
- "print str(sys.getsizeof(array) / sys.getsizeof(int)) + \"\\n\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Size of array: 64bytes\n",
- "\n",
- "Number of elements in array \n",
- "0\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 10.3, Page No 231"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "# there is no malloc function"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 10.4, Page No 232"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "# there is no malloc function"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 10.5, Page No 232"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "# there is no malloc function"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 10.6, Page No 233"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "# there is no malloc function\n",
- "#if name is None:\n",
- "# print \"\\nOut of memory!\\n\"\n",
- "#else:\n",
- "# print \"\\nMemory allocated.\\n\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 10.7, Page No 234"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "# there is no malloc function\n",
- "#if name is not None:\n",
- "# name = raw_input(\"Enter your name: \")\n",
- "# print \"\\nHi \" + name + \"\\n\" "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 10.8, Page No 235"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "# there is no malloc function\n",
- "#if name is not None:\n",
- "# name = raw_input(\"Enter your name: \")\n",
- "# print \"\\nHi \" + name + \"\\n\"\n",
- "# del name"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 10
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 10.9, Page No 236"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "# there is no malloc function\n",
- "#if numbers is None:\n",
- "# return\n",
- "#numbers[0] = 100\n",
- "#numbers[1] = 200\n",
- "#numbers[2] = 300\n",
- "#numbers[3] = 400\n",
- "#numbers[4] = 500\n",
- "#print \"\\nIndividual memory segments initialized to:\\n\"\n",
- "#for x in range(5):\n",
- "# print \"numbers[\" +x+\"] = \\n\" + numbers[x]"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 16
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 10.10, Page No 237"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "# there is no calloc function\n",
- "#if numbers is None:\n",
- "# return"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 17
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 10.11, Page No 239"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "# there is no malloc function\n",
- "#if numbers is None:\n",
- "# print \"\\nOut of memory!\\n\"\n",
- "# return\n",
- "#else:\n",
- "# number = newNumber\n",
- "# for x in range(10):\n",
- "# numbers[x] = x * 10\n",
- "# print \"\\nExpanded memory:\\n\"\n",
- "# for x in range(10):\n",
- "# print \"numbers[\" +x+\"] = \\n\" + numbers[x]\n",
- "# del number"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 18
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 10.12, Page No 241"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import random\n",
- "# there is no calloc function\n",
- "#time\n",
- "#print \"\\nMath Quiz\\n\\n\"\n",
- "#response = raw_input(\"Enter # of problems: \")\n",
- "#if op1 is None || op2 is None || answer is None ||result is None:\n",
- "# print \"\\nOut of Memory!\\n\"\n",
- "# return\n",
- "#for x in range(response):\n",
- "# op1[x] = random.randint(1,200) % 100\n",
- "# op2[x] = random.randint(1,200) % 100\n",
- "# print \"\\n\" + op1[x] + \"+\" + op2[x]\"\n",
- "# answer[x] = raw_input(\"\")\n",
- "# if answer[x] == op1[x] + op2[x]:\n",
- "# result[x] = 'c'\n",
- "# else:\n",
- "# result[x] = 'i'\n",
- "#print \"\\nQuiz Results\\n\"\n",
- "#print \"\\nQuestion\\tYour Answer\\tCorrect\\n\"\n",
- "#for x in range(response):\n",
- "# if result[x] == 'c':\n",
- "# print op1[x] + \"+\" + op2[x] + \"\\t\\t\" + answer[x] + \"\\t\\tYes\\n\"\n",
- "# else:\n",
- "# print op1[x] + \"+\" + op2[x] + \"\\t\\t\" + answer[x] + \"\\t\\tNo\\n\"\n",
- "#del op1\n",
- "#del op2\n",
- "#del answer\n",
- "#del result "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 20
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/C_Programming_for_the_Absolute_Beginner/Chapter11.ipynb b/C_Programming_for_the_Absolute_Beginner/Chapter11.ipynb
deleted file mode 100755
index 239b6ca4..00000000
--- a/C_Programming_for_the_Absolute_Beginner/Chapter11.ipynb
+++ /dev/null
@@ -1,616 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:9d02541e3ea8d7af1efd977534b7150b993557acd6da8dc30b83dcacb798d681"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 11 : File Input and Output"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 11.1, Page No 250"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "try:\n",
- " pRead = open(\"file1.dat\",\"r\")\n",
- "except IOError:\n",
- " print \"\\nFile can not be opened\\n\"\n",
- "\n",
- "\"\"\"\n",
- "Input file:- file1.dat\n",
- "\"\"\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 11.2, Page No 252"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "try:\n",
- " pRead = open(\"file1.dat\",\"r\")\n",
- " if(not isinstance(pRead,file)):\n",
- " print \"\\nFile can not be opened\\n\"\n",
- " else:\n",
- " print \"\\nFile opened for reading\\n\"\n",
- " pRead.close()\n",
- "except IOError:\n",
- " print \"\\nFile can not be opened\\n\"\n",
- "\n",
- "\"\"\"\n",
- "Input file:- file1.dat\n",
- "\"\"\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "File opened for reading\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 11.3, Page No 253"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "try:\n",
- " pRead = open(\"names.dat\",\"r\")\n",
- " if(not isinstance(pRead,file)):\n",
- " print \"\\nFile can not be opened\\n\"\n",
- " else:\n",
- " print \"\\nContents of names.dat\\n\"\n",
- " while(1):\n",
- " t = pRead.readline() \n",
- " if(t != \"\"):\n",
- " print t\n",
- " else:\n",
- " break\n",
- " pRead.close()\n",
- "except IOError:\n",
- " print \"\\nFile can not be opened\\n\"\n",
- " \n",
- "\"\"\" \n",
- "Input File :- names.dat\n",
- "\n",
- "Michael\n",
- "Sheila\n",
- "Spencer\n",
- "Olivia\n",
- "\n",
- "\"\"\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Contents of names.dat\n",
- "\n",
- "Michael\n",
- "\n",
- "Sheila\n",
- "\n",
- "Spencer\n",
- "\n",
- "Olivia\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 11.4, Page No 255"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "try:\n",
- " pRead = open(\"hobbies.dat\",\"r\")\n",
- " if(not isinstance(pRead,file)):\n",
- " print \"\\nFile can not be opened\\n\"\n",
- " else:\n",
- " print \"\\nName\\tHobby\\n\\n\"\n",
- " while(1):\n",
- " name = pRead.readline()\n",
- " hobby = pRead.readline()\n",
- " if(name != \"\"):\n",
- " print name + \"\\t\"\n",
- " print hobby\n",
- " else:\n",
- " break\n",
- " pRead.close()\n",
- "except IOError:\n",
- " print \"\\nFile can not be opened\\n\"\n",
- " \n",
- "\"\"\"\n",
- "Input file :- hobbies.dat\n",
- "\n",
- "Michael\tProgramming\n",
- "Sheila\tShopping\n",
- "Spencer\tFootball\n",
- "Olivia\tDancing\n",
- "Waytt\tEating\n",
- "\"\"\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Name\tHobby\n",
- "\n",
- "\n",
- "Michael\tProgramming\n",
- "\t\n",
- "Sheila\tShopping\n",
- "\n",
- "Spencer\tFootball\n",
- "\t\n",
- "Olivia\tDancing\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 11.5, Page No 256"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "try:\n",
- " pWrite = open(\"students.dat\",\"w\")\n",
- " if(not isinstance(pWrite,file)):\n",
- " print \"\\nFile can not be opened\\n\"\n",
- " else:\n",
- " fname = raw_input(\"Enter first name: \")\n",
- " lname = raw_input(\"Enter last name: \")\n",
- " id1 = raw_input(\"Enter id: \")\n",
- " gpa = float(raw_input(\"Enter GPA: \"))\n",
- " pWrite.writelines(fname + \" \" + lname + \"\\t\" + id1 + \"\\t\" + str(gpa))\n",
- " pWrite.close()\n",
- "except IOError:\n",
- " print \"\\nFile can not be opened\\n\"\n",
- "\n",
- "\"\"\"\n",
- "Output file:- students.dat\n",
- "Patric Star\t888-66-9999\t2.0\n",
- "\"\"\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter first name: Patric\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter last name: Star\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter id: 888-66-9999\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter GPA: 2.00\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 11.6, Page No 258"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "try:\n",
- " pRead = open(\"students.dat\",\"r\")\n",
- " if(not isinstance(pRead,file)):\n",
- " print \"\\nFile can not be opened\\n\"\n",
- " else:\n",
- " print \"\\nName\\t\\tID\\t\\tGPA\\n\\n\"\n",
- " while(1):\n",
- " fname = pRead.read()\n",
- " lname = pRead.read()\n",
- " id1 = pRead.read()\n",
- " gpa = pRead.read()\n",
- " \n",
- " if(fname != \"\"):\n",
- " print fname + lname + \"\\t\\t\" + id1 + \"\\t\" + str(gpa)\n",
- " else:\n",
- " break\n",
- " pRead.close()\n",
- "except IOError:\n",
- " print \"\\nFile can not be opened\\n\"\n",
- "\n",
- "\"\"\"\n",
- "Input file:- students.dat\n",
- "Patric Star\t888-66-9999\t2.0\n",
- "\"\"\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Name\t\tID\t\tGPA\n",
- "\n",
- "\n",
- "Patric Star\t888-66-9999\t2.0\t\t\t\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 11.7, Page No 259"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def readData():\n",
- " try:\n",
- " pRead = open(\"hobbies.dat\",\"r\")\n",
- " if(not isinstance(pRead,file)):\n",
- " print \"\\nFile can not be opened\\n\"\n",
- " else:\n",
- " print \"\\nName\\tHobby\\n\\n\"\n",
- " while(1):\n",
- " name = pRead.readline()\n",
- " hobby = pRead.readline()\n",
- " if(name != \"\"):\n",
- " print name + \"\\t\"\n",
- " print hobby\n",
- " else:\n",
- " break\n",
- " pRead.close()\n",
- " except IOError:\n",
- " print \"\\nFile can not be opened\\n\"\n",
- "try:\n",
- " print \"Current file contains\"\n",
- " readData()\n",
- " print \"\\n\"\n",
- " name = raw_input(\"Enter a new name: \")\n",
- " hobby = raw_input(\"Enter a new hobby: \")\n",
- " pWrite = open(\"hobbies.dat\",\"a\")\n",
- " if(not isinstance(pWrite,file)):\n",
- " print \"\\nFile can not be opened\\n\"\n",
- " else:\n",
- " pWrite.writelines(\"\\n\" + name + \"\\t\" + hobby)\n",
- " pWrite.close()\n",
- " readData()\n",
- "except IOError:\n",
- " print \"\\nFile can not be opened\\n\"\n",
- " \n",
- "\"\"\"\n",
- "Input file and Output file:- hobbies.dat\n",
- "Michael\tProgramming\n",
- "Sheila\tShopping\n",
- "Spencer\tFootball\n",
- "Olivia\tDancing\n",
- "Waytt\tEating\n",
- "\"\"\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Current file contains\n",
- "\n",
- "Name\tHobby\n",
- "\n",
- "\n",
- "Michael\tProgramming\n",
- "\t\n",
- "Sheila\tShopping\n",
- "\n",
- "Spencer\tFootball\n",
- "\t\n",
- "Olivia\tDancing\n",
- "\n",
- "\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a new name: Waytt\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a new hobby: Eating\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Name\tHobby\n",
- "\n",
- "\n",
- "Michael\tProgramming\n",
- "\t\n",
- "Sheila\tShopping\n",
- "\n",
- "Spencer\tFootball\n",
- "\t\n",
- "Olivia\tDancing\n",
- "\n",
- "Waytt\tEating\t\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 11.8, Page No 263"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import sys\n",
- "try:\n",
- " pRead = open(\"hobbies.dat\",\"r\")\n",
- " if(not isinstance(pRead,file)):\n",
- " print \"\\nFile can not be opened\\n\"\n",
- " print \"The following error occurred\" #goto label\n",
- " sys.exit(\"Some Error Occures\")\n",
- " else:\n",
- " print \"\\nName\\tHobby\\n\\n\"\n",
- " while(1):\n",
- " name = pRead.readline()\n",
- " hobby = pRead.readline()\n",
- " if(name != \"\"):\n",
- " print name + \"\\t\"\n",
- " print hobby\n",
- " else:\n",
- " break\n",
- " pRead.close()\n",
- " #sys.exit(\"Exit\")\n",
- "except IOError:\n",
- " print \"\\nFile can not be opened\\n\"\n",
- "\n",
- "\"\"\"\n",
- "Input file:- hobbies.dat\n",
- "Michael\tProgramming\n",
- "Sheila\tShopping\n",
- "Spencer\tFootball\n",
- "Olivia\tDancing\n",
- "Waytt\tEating\n",
- "\"\"\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Name\tHobby\n",
- "\n",
- "\n",
- "Michael\tProgramming\n",
- "\t\n",
- "Sheila\tShopping\n",
- "\n",
- "Spencer\tFootball\n",
- "\t\n",
- "Olivia\tDancing\n",
- "\n",
- "Waytt\tEating\t\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 20
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 11.9, Page No 266"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "print \"\\n\\tPhone Book\\n\"\n",
- "print \"\\n 1 \\t Add phone book entry \\n\"\n",
- "print \"2 \\t Print phone book \\n\\n\"\n",
- "print \"Select an option: \"\n",
- "response = int(raw_input(\"Select an option: \"))\n",
- "print response\n",
- "if(response == 1):\n",
- " fname = raw_input(\"Enter first name: \")\n",
- " lname = raw_input(\"Enter last name: \")\n",
- " number = raw_input(\"Enter phone number: \")\n",
- " pWrite = open(\"phone_book.dat\",\"a\")\n",
- " if(isinstance(pWrite,file)):\n",
- " pWrite.writelines(fname + \" \" + lname + \" \" + number + \"\\n\")\n",
- " pWrite.close()\n",
- " else:\n",
- " print \"The error occured\" #go to\n",
- "elif(response == 2):\n",
- " pRead = open(\"phone_book.dat\",\"r\")\n",
- " if(isinstance(pRead,file)):\n",
- " while(1):\n",
- " fname = pRead.read()\n",
- " if(fname == \"\"):\n",
- " break\n",
- " lname = pRead.read()\n",
- " number = pRead.read()\n",
- " print fname\n",
- " print lname\n",
- " print number\n",
- " print \"\\n\"\n",
- " else:\n",
- " print \"The error occured\" #go to\n",
- "else:\n",
- " print \"Invalid Selection\"\n",
- "\n",
- "\"\"\"\n",
- "Input file and Output file:- phone_book.dat\n",
- "John Smith 538.676.1234\n",
- "\"\"\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "\tPhone Book\n",
- "\n",
- "\n",
- " 1 \t Add phone book entry \n",
- "\n",
- "2 \t Print phone book \n",
- "\n",
- "\n",
- "Select an option: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Select an option: 2\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "2\n",
- "John Smith 538.676.1234\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 1
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/C_Programming_for_the_Absolute_Beginner/Chapter12.ipynb b/C_Programming_for_the_Absolute_Beginner/Chapter12.ipynb
deleted file mode 100755
index 76d70f5c..00000000
--- a/C_Programming_for_the_Absolute_Beginner/Chapter12.ipynb
+++ /dev/null
@@ -1,445 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:b5b5db464e530d21c4b695ff4bde6912d0e8c447d51f1ede515f161acac3856f"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 12 : The C PreProcessor"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 12.1, Page No 272"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "print \"\\nHaving fun with preprocessor directives\\n\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Having fun with preprocessor directives\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 12.2, Page No 273"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "NUMBER = 7\n",
- "print \"\\nLucky Number \", NUMBER , \"\\n\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Lucky Number 7 \n",
- "\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 12.3, Page No 274"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "NUMBER = 7\n",
- "print \"\\nLucky Number \", NUMBER , \"\\n\"\n",
- "NUMBER = 5"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Lucky Number 7 \n",
- "\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 12.4, Page No 275"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def area(l,w):\n",
- " return l * w\n",
- "length = 0\n",
- "width = 0\n",
- "length = int(raw_input(\"\\nEnter length: \"))\n",
- "width = int(raw_input(\"\\nEnter width: \"))\n",
- "print \"\\nArea of rectangle = \" , area(length,width) , \"\\n\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Enter length: 12\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Enter width: 7\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Area of rectangle = 84 \n",
- "\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 12.5, Page No 276"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def RESULT(x,y):\n",
- " print \"\\nResult is \\n\", x+y\n",
- "num1 = 0\n",
- "num2 = 0\n",
- "num1 = int(raw_input(\"\\nEnter first number: \"))\n",
- "num2 = int(raw_input(\"\\nEnter second number: \"))\n",
- "RESULT(num1,num2)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Enter first number: 27\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Enter second number: 44\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Result is \n",
- "71\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 12.6, Page No 277"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def RESULT(x,y):\n",
- " print \"\\nResult is \\n\", x+y\n",
- "operand1 = 0\n",
- "operand2 = 0\n",
- "operand1 = int(raw_input(\"\\nEnter first operand: \"))\n",
- "operand2 = int(raw_input(\"\\nEnter second operand: \"))\n",
- "RESULT(operand1,operand2)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Enter first operand: 27\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Enter second operand: 44\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Result is \n",
- "71\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 12.7, Page No 279"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import profit\n",
- "print \"\\nThe Profit Program\\n\"\n",
- "price = float(raw_input(\"\\nEnter unit price: \"))\n",
- "quantity = int(raw_input(\"Enter quantity sold: \"))\n",
- "totalCost = float(raw_input(\"Enter total cost: \"))\n",
- "profit1(price,quantity,totalCost)\n",
- "\n",
- "\"\"\"\n",
- "Header file:- profit.py\n",
- "def profit(p,q,tc):\n",
- " print \"\\nYour profit is \",(p * q) - tc,\"\\n\"\n",
- "\"\"\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "The Profit Program\n",
- "\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Enter unit price: 12.99\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter quantity sold: 7\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter total cost: 56\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Your profit is 34.93 \n",
- "\n"
- ]
- }
- ],
- "prompt_number": 22
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 12.8, Page No 282"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import calculate\n",
- "selection = 0\n",
- "print \"\\n The Function Wizard \\n\"\n",
- "print \"\\n1\\tDetermine perimeter of ractangle\\n\"\n",
- "print \"\\n2\\tDetermine area of rectangle\\n\"\n",
- "print \"\\n3\\tDetermine volume of rectangle\\n\"\n",
- "selection = int(raw_input(\"\\nEnter selection : \"))\n",
- "if selection == 1:\n",
- " l = float(raw_input(\"Enter length: \"))\n",
- " w = float(raw_input(\"Enter width: \"))\n",
- " perimeter(l,w)\n",
- "elif selection == 2:\n",
- " l = float(raw_input(\"Enter length: \"))\n",
- " w = float(raw_input(\"Enter width: \"))\n",
- " area(l,w)\n",
- "elif selection == 3:\n",
- " l = float(raw_input(\"Enter length: \"))\n",
- " w = float(raw_input(\"Enter width: \"))\n",
- " h = float(raw_input(\"Enter height: \"))\n",
- " volume(l,w,h)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- " The Function Wizard \n",
- "\n",
- "\n",
- "1\tDetermine perimeter of ractangle\n",
- "\n",
- "\n",
- "2\tDetermine area of rectangle\n",
- "\n",
- "\n",
- "3\tDetermine volume of rectangle\n",
- "\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Enter selection : 3\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter length: 1\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter width: 2\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter height: 3\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- " Perimeter is 6.0 \n",
- "\n"
- ]
- }
- ],
- "prompt_number": 5
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/C_Programming_for_the_Absolute_Beginner/Chapter2.ipynb b/C_Programming_for_the_Absolute_Beginner/Chapter2.ipynb
deleted file mode 100755
index 2f3c44af..00000000
--- a/C_Programming_for_the_Absolute_Beginner/Chapter2.ipynb
+++ /dev/null
@@ -1,239 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:622f2c579033e8c66b476e16d61ce8bfa6745f6b87c5905b2064108fa5218b3c"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 2 PRIMARY DATA TYPES"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 2.1, Page No. 32"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "x=-4443\n",
- "y=554.21\n",
- "c='M'\n",
- "\n",
- "print \"The value of integer variable x is\" , x\n",
- "print \"The value of float variable y is \" , y\n",
- "print \"The value of character variable c is \" , c"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of integer variable x is -4443\n",
- "The value of float variable y is 554.21\n",
- "The value of character variable c is M\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 2.2, Page No. 36"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "x = 20\n",
- "PI = 3.14\n",
- "print \"Constant values are \",x ,\" and \", round(PI,2)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Constant values are 20 and 3.14\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 2.3, Page No. 42"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "print \"\\t Adder Program, by Michael Vine\"\n",
- "iOperand1=int(raw_input(\"Enter First Operand: \"))\n",
- "iOperand2=int(raw_input(\"Enter Second Operand: \"))\n",
- "print \"The final result is \", iOperand1+iOperand2"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\t Adder Program, by Michael Vine\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter First Operand: 5\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter Second Operand: 7\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The final result is 12\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 2.4, Page No. 44"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "print \"\\t Adder Program, by Michael Vine\"\n",
- "iOperand1=int(raw_input(\"Enter First Operand: \"))\n",
- "iOperand2=int(raw_input(\"Enter Second Operand: \"))\n",
- "iResult=iOperand1+iOperand2\n",
- "print \"The result is \", iResult"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\t Adder Program, by Michael Vine\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter First Operand: 5\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter Second Operand: 7\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The result is 12\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 2.5, Page No. 46"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "fRevenue=float(raw_input(\"Enter total revenue: \"))\n",
- "fCost=float(raw_input(\"Enter total cost: \"))\n",
- "print \"Your total profit is \", round(fRevenue-fCost,3)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter total revenue: 4000\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter total cost: 750\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Your total profit is 3250.0\n"
- ]
- }
- ],
- "prompt_number": 3
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/C_Programming_for_the_Absolute_Beginner/Chapter3.ipynb b/C_Programming_for_the_Absolute_Beginner/Chapter3.ipynb
deleted file mode 100755
index a87e263b..00000000
--- a/C_Programming_for_the_Absolute_Beginner/Chapter3.ipynb
+++ /dev/null
@@ -1,499 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:4698a1abef67d23e99c2eb6e9534a43d9d501d3ae6147f6ceb242f76f06f63a5"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 3 CONDITIONS"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 3.1, Page No. 58"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "print \"\\tAC Control Unit\"\n",
- "print \"1\\tTurn the AC on\"\n",
- "print \"2\\tTurn the AC off\"\n",
- "iResponse=int(raw_input(\"Enter your selection::\"))\n",
- "if iResponse==1:\n",
- " print \"AC is now on\"\n",
- "if iResponse==2:\n",
- " print \"AC is now off\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\tAC Control Unit\n",
- "1\tTurn the AC on\n",
- "2\tTurn the AC off\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter your selection::1\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "AC is now on\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 3.2, Page No. 59"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "print \"\\tAC Control Unit\"\n",
- "print \"a\\tTurn the AC on\"\n",
- "print \"b\\tTurn the AC off\"\n",
- "cResponse=raw_input(\"Enter your selection::\")\n",
- "if cResponse=='a':\n",
- " print \"AC is now on\"\n",
- "if cResponse=='b':\n",
- " print \"AC is now off\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\tAC Control Unit\n",
- "a\tTurn the AC on\n",
- "b\tTurn the AC off\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter your selection::b\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "AC is now off\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 3.3, Page No. 61"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "fBalance = 100.25\n",
- "print \"\\tATM\"\n",
- "print \"1\\tDeposit Funds\"\n",
- "print \"2\\tWithdraw Funds\"\n",
- "iSelection=int(raw_input(\"Enter Your Selection: \"))\n",
- "if iSelection==1:\n",
- " fTransAmount=int(raw_input(\"Enter fund amount to deposit: \"))\n",
- " print \"Your new Balance is: \", fBalance+fTransAmount\n",
- "if iSelection==2:\n",
- " fTransAmount=int(raw_input(\"Enter fund amount to withdraw: \"))\n",
- " if fTransAmout>fBalance:\n",
- " print \"Insufficient Funds\"\n",
- " else:\n",
- " print \"Your new balance is \", fBalance-fTransAmount"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\tATM\n",
- "1\tDeposit Funds\n",
- "2\tWithdraw Funds\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter Your Selection: 1\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter fund amount to deposit: 200\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Your new Balance is: 300.25\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 3.4, Page No. 67"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "cResponse=raw_input(\"Enter a letter A: \")\n",
- "if cResponse=='A':\n",
- " print \"Correct response\"\n",
- "else:\n",
- " print \"Incorrect response\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a letter A: a\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Incorrect response\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 3.5, Page No.69"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "iResponse=int(raw_input(\"Enter a numeer from 1 to 10: \"))\n",
- "if iResponse<1 or iResponse>10:\n",
- " print \"Number not in Range\"\n",
- "else:\n",
- " print \"Thank You\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a numeer from 1 to 10: 5\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Thank You\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 3.6, Page No. 70"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "cResponse=raw_input(\"Please Enter a letter: \")\n",
- "if not cResponse.isdigit():\n",
- " print \"Thank You\"\n",
- "else:\n",
- " print \"You did not enter a letter\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Please Enter a letter: 5\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "You did not enter a letter\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 3.7, Page No. 70"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "cResponse=raw_input(\"Please Enter a letter: \")\n",
- "if cResponse.isdigit():\n",
- " print \"Thank You\"\n",
- "else:\n",
- " print \"You did not enter a digit\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Please Enter a letter: a\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "You did not enter a digit\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 3.8, Page No.72"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "print \"1\\tSports\"\n",
- "print \"2\\tGeography\"\n",
- "print \"3\\tMusic\"\n",
- "print \"4\\tWorld Events\"\n",
- "iResponse=int(raw_input(\"Please select a category (1-4): \"))\n",
- "if iResponse==1:\n",
- " print \"You selected sports questions\"\n",
- "elif iResponse==2:\n",
- " print \"You selected geography questions\"\n",
- "elif iResponse==3:\n",
- " print \"You selected Music questions\"\n",
- "elif iResponse==4:\n",
- " print \"You selected World event questions\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "1\tSports\n",
- "2\tGeography\n",
- "3\tMusic\n",
- "4\tWorld Events\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Please select a category (1-4): 4\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "You selected World event questions\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 3.9, Page No. 75"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import random\n",
- "iRandomNum=(random.randint(0,100)%10)+1\n",
- "iResponse=int(raw_input(\"Guess a number between 1 and 10: \"))\n",
- "if iResponse==iRandomNum:\n",
- " print \"You guessed right\"\n",
- "else:\n",
- " print \"Sorry, you guess wrong\"\n",
- " print \"The correct guess was \",iRandomNum"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Guess a number between 1 and 10: 2\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Sorry, you guess wrong\n",
- "The correct guess was 3\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 3.10, Page No. 77"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import random\n",
- "iRandomNum=(random.randint(0,100)%4)+1\n",
- "print \"Fortune Cookie - Chapter 3\"\n",
- "if iRandomNum==1:\n",
- " print \"You will meet a new friend\"\n",
- "elif iRandomNum==2:\n",
- " print \"You will enjoy a long and happy life\"\n",
- "elif iRandomNum==3:\n",
- " print \"Opportunity knocks softly. Can you hear it?\"\n",
- "elif iRandomNum==4:\n",
- " print \"You'll be financially rewarded for your good deeds\"\n",
- "\n",
- "print \"Lucky lotto numbers\"\n",
- "print (random.randint(0,100)%49+1)\n",
- "print (random.randint(0,100)%49+1)\n",
- "print (random.randint(0,100)%49+1)\n",
- "print (random.randint(0,100)%49+1)\n",
- "print (random.randint(0,100)%49+1)\n",
- "print (random.randint(0,100)%49+1)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Fortune Cookie - Chapter 3\n",
- "You will enjoy a long and happy life\n",
- "Lucky lotto numbers\n",
- "45\n",
- "17\n",
- "9\n",
- "23\n",
- "2\n",
- "15\n"
- ]
- }
- ],
- "prompt_number": 13
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/C_Programming_for_the_Absolute_Beginner/Chapter4.ipynb b/C_Programming_for_the_Absolute_Beginner/Chapter4.ipynb
deleted file mode 100755
index 218595de..00000000
--- a/C_Programming_for_the_Absolute_Beginner/Chapter4.ipynb
+++ /dev/null
@@ -1,688 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:d985967b3e8d0e583d78d0a3306851320f330cc48579a1f62da314746570750f"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 4 Looping Structures"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 4.1 , Page No.88"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "x=0\n",
- "print \"The value of x is \",x\n",
- "x+=1\n",
- "print \"The value of x is \",x"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of x is 0\n",
- "The value of x is 1\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 4.2, Page No.89"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "x=0\n",
- "y=0\n",
- "print \"The value of y is \", y+1\n",
- "print \"The value of x is \", x+1"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of y is 1\n",
- "The value of x is 1\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 4.3, Page No.89"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "x=0\n",
- "y=1\n",
- "x=(y)*2\n",
- "print \"The Value of x \",x\n",
- "x=0\n",
- "y=1\n",
- "x=(y+1)*2\n",
- "print \"The Value of x \",x"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The Value of x 2\n",
- "The Value of x 4\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 4.4, Page No.90"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "x=0\n",
- "y=0\n",
- "x=(y)*4\n",
- "print \"The Value of x\", x\n",
- "y=0\n",
- "x=(y+1)*4\n",
- "print \"The Value of x\", x"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The Value of x 0\n",
- "The Value of x 4\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 4.5, Page No.92"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "x=1\n",
- "y=1\n",
- "x=(y)*4\n",
- "print \"The value of x is \",x\n",
- "y=1\n",
- "x=(y-1)*4\n",
- "print \"The value of x is \",x"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of x is 4\n",
- "The value of x is 0\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 4.6, Page No. 93"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "x=1\n",
- "y=2\n",
- "x=y*x+1\n",
- "print \"The value of x is: \",x\n",
- "x=1\n",
- "y=2\n",
- "x+=y*x+1\n",
- "print \"The value of x is: \",x"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of x is: 3\n",
- "The value of x is: 4\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 4.7, Page No.94"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "x=1\n",
- "y=2\n",
- "x=y*x+1\n",
- "print \"The value of x is: \",x\n",
- "x=1\n",
- "y=2\n",
- "x-=y*x+1\n",
- "print \"The value of x is: \",x"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of x is: 3\n",
- "The value of x is: -2\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 4.8, Page No.95"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "x=0\n",
- "while (x<10):\n",
- " print \"The value of x is \",x\n",
- " x=x+1"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of x is 0\n",
- "The value of x is 1\n",
- "The value of x is 2\n",
- "The value of x is 3\n",
- "The value of x is 4\n",
- "The value of x is 5\n",
- "The value of x is 6\n",
- "The value of x is 7\n",
- "The value of x is 8\n",
- "The value of x is 9\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 4.9, Page No.97"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "iSelection=0\n",
- "while (iSelection!=4):\n",
- " print \"1\\tDeposit Funds\"\n",
- " print \"2\\tWithdraw Funds\"\n",
- " print \"3\\tPrint Balance\"\n",
- " print \"4\\tQuit\"\n",
- " iSelection=int(raw_input(\"Enter Your Selection(1-4): \"))\n",
- "print \"Thank you\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "1\tDeposit Funds\n",
- "2\tWithdraw Funds\n",
- "3\tPrint Balance\n",
- "4\tQuit\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter Your Selection(1-4): 1\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "1\tDeposit Funds\n",
- "2\tWithdraw Funds\n",
- "3\tPrint Balance\n",
- "4\tQuit\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter Your Selection(1-4): 4\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Thank you\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 4.10, Page No.99"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "x=9\n",
- "while (x<10):\n",
- " print \"This printf statement is executed at least once\"\n",
- " x=x+1\n",
- "while (x<10):\n",
- " print \"This printf statement is never executed \"\n",
- " x=x+1"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "This printf statement is executed at least once\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 4.11, Page No.100"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "for x in range(10,5,-1):\n",
- " print \"The value of x is \",x"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of x is 10\n",
- "The value of x is 9\n",
- "The value of x is 8\n",
- "The value of x is 7\n",
- "The value of x is 6\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 4.12, Page No.101"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import random\n",
- "iNumQuestions=int(raw_input(\"Enter the number of questions to ask: \"))\n",
- "for x in range(iNumQuestions):\n",
- " iRndNum1=(random.randint(0,100)%10)+1\n",
- " iRndNum2=(random.randint(0,100)%10)+1\n",
- " iResponse=int(raw_input(\"what is \"+ str(iRndNum1)+\" * \"+str(iRndNum2)+\" : \"))\n",
- " if(iResponse==(iRndNum1*iRndNum2)):\n",
- " print \"Correct\"\n",
- " else:\n",
- " print \"The Corrent answer was \", iRndNum1*iRndNum2"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter the number of questions to ask: 2\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "what is 6 * 9 : 54\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Correct\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "what is 8 * 5 : 32\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The Corrent answer was 40\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 4.13, Page No.102"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "for x in range(10,5,-1):\n",
- " if x==7:\n",
- " break\n",
- "print x"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "7\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 4.14, Page No.103"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "for x in range(10,5,-1):\n",
- " if x==7:\n",
- " continue\n",
- " print x"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "10\n",
- "9\n",
- "8\n",
- "6\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 4.15, Page No.104"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "for x in range(25):\n",
- " print \"\\n\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 4.16, Page No. 106"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import time\n",
- "import random\n",
- "import os\n",
- "cYesNo=raw_input(\"Play a game of Concentration?(y or n)\")\n",
- "if(cYesNo=='y' or cYesNo=='Y'):\n",
- " i1=random.randint(0,100) % 100\n",
- " i2=random.randint(0,100) % 100\n",
- " i3=random.randint(0,100) % 100\n",
- " print \"Concentrate on the next three numbers\\n\",i1,i2,i3\n",
- " iCurrentTime=int(round(time.time()*1000))\n",
- " iElapsedTime=int(round(time.time()*1000))\n",
- " while((iCurrentTime-iElapsedTime)<3):\n",
- " iElapsedTime=int(round(time.time()*1000))\n",
- " os.system('cls')\n",
- " iResp1=int(raw_input(\"Enter a number:\"))\n",
- " iResp2=int(raw_input(\"Enter a number:\"))\n",
- " iResp3=int(raw_input(\"Enter a number:\"))\n",
- " \n",
- " if(i1==iResp1 and i2==iResp2 and i3==iResp3):\n",
- " print \"Congratulations!\"\n",
- " else:\n",
- " print \"Sorry, Correct numbers were \",i1,i2,i3"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Play a game of Concentration?(y or n)n\n"
- ]
- }
- ],
- "prompt_number": 1
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/C_Programming_for_the_Absolute_Beginner/Chapter5.ipynb b/C_Programming_for_the_Absolute_Beginner/Chapter5.ipynb
deleted file mode 100755
index ac86dba8..00000000
--- a/C_Programming_for_the_Absolute_Beginner/Chapter5.ipynb
+++ /dev/null
@@ -1,475 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:22dbf664bff583df60a7371a6f741be85c976f32fe9bef5f00f146ca5848d933"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 5 : Structured Programming"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.1, Page No 116"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def addTwoNumbers(operand1,operand2):\n",
- " return operand1+operand2\n",
- "\n",
- "print \"Nothing happenning here\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Nothing happenning here\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.2, Page No 118"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def addTwoNumbers(num1,num2):\n",
- " return num1+num2\n",
- "\n",
- "def subtractTwoNumber(num1,num2):\n",
- " return num1-num2\n",
- "\n",
- "print \"Nothing happenning here\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Nothing happenning here\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.3, Page No 119"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def addTwoNumbers(operand1,operand2):\n",
- " return operand1+operand2\n",
- "\n",
- "\n",
- "iResult= addTwoNumbers(5,5)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.4, Page No 120"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def addTwoNumbers(operand1,operand2):\n",
- " return operand1+operand2\n",
- "\n",
- "print \"The result is : \",addTwoNumbers(5,5)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The result is : 10\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.5, Page No 120"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def addTwoNumbers(operand1,operand2):\n",
- " return operand1+operand2\n",
- "\n",
- "num1=int(raw_input(\"Enter the first number: \"))\n",
- "num2=int(raw_input(\"Enter the second number: \"))\n",
- "print \"The result is: \",addTwoNumbers(num1,num2)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter the first number: 57\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter the second number: 43\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The result is: 100\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.6, Page No 121"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def printReportHeader():\n",
- " print \"\\n Column1 \\t Column2 \\t Column3 \\t Column4 \\n\"\n",
- " \n",
- "printReportHeader()"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- " Column1 \t Column2 \t Column3 \t Column4 \n",
- "\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.7, Page No 122"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "num1=int(raw_input(\"Enter a number: \"))\n",
- "print \"You entered \",num1"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a number: 10\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "You entered 10\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.8, Page No 123"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def getSecondNumber():\n",
- " num1=int(raw_input(\"Enter Second number: \"))\n",
- " return num1\n",
- "\n",
- "num1=int(raw_input(\"Enter a number: \"))\n",
- "num2=getSecondNumber()\n",
- "print \"you entered \"+str(num1)+\" and \",str(num2)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a number: 28\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter Second number: 35\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "you entered 28 and 35\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.9, Page No 124"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "iLuckyNumber=int()\n",
- "def printLuckyNumber():\n",
- " print \"Your lucky number is: \",iLuckyNumber\n",
- "\n",
- "\n",
- "iLuckyNumber=int(raw_input(\"Enter your lucky number: \"))\n",
- "printLuckyNumber()"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter your lucky number: 10\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Your lucky number is: 10\n"
- ]
- }
- ],
- "prompt_number": 19
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 5.10, Page No 126"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import os\n",
- "import time\n",
- "def sportsQuestion():\n",
- " print \"Sports Question\"\n",
- " print \"What University did NFL star Deon Sanders attend?\"\n",
- " print \"1 \\t University of Miami\"\n",
- " print \"2 \\t California State University\"\n",
- " print \"3 \\t Indiana University\"\n",
- " print \"4 \\t Florida State University\"\n",
- " iAnswer=int(raw_input(\"Enter your selection :\"))\n",
- " return iAnswer\n",
- "\n",
- "def geographyQuestion():\n",
- " print \"Geography Question\"\n",
- " print \"What is the state capitol of Florida?\"\n",
- " print \"1 \\t Pensecola\"\n",
- " print \"2 \\t Tallahassee\"\n",
- " print \"3 \\t Jacksonville\"\n",
- " print \"4 \\t Miami\"\n",
- " iAnswer=int(raw_input(\"Enter your selection :\"))\n",
- " return iAnswer\n",
- "def pause(inNum):\n",
- " iCurrentTime=0\n",
- " iElapsedTime=0\n",
- " \n",
- " iCurrentTime=int(round(time.time()*1000))\n",
- " \n",
- " while((iElapsedTime-iCurrentTime)<inNum):\n",
- " iElapsedTime=int(round(time.time()*1000))\n",
- "\n",
- "giResponse=0\n",
- "while(giResponse !=3):\n",
- " os.system('cls')\n",
- " print \"\\n\\tTHE TRIVIA GAME\\n\\n\"\n",
- " print \"1\\tSports\\n\"\n",
- " print \"2\\tGeography\\n\"\n",
- " print \"3\\tQuit\\n\"\n",
- " giResponse=int(raw_input(\"Enter your Selection: \"))\n",
- " \n",
- " if(giResponse==1):\n",
- " if(sportsQuestion()==4):\n",
- " print \"\\nCorrect\\n\"\n",
- " else:\n",
- " print \"\\nIncorrect\\n\"\n",
- " \n",
- " pause(2)\n",
- " break\n",
- " elif(giResponse==2):\n",
- " if(geographyQuestion()==2):\n",
- " print \"\\nCorrect\\n\"\n",
- " else:\n",
- " print \"\\nIncorrect\\n\"\n",
- " \n",
- " pause(2)\n",
- " break\n",
- " \n",
- " \n",
- " "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "\tTHE TRIVIA GAME\n",
- "\n",
- "\n",
- "1\tSports\n",
- "\n",
- "2\tGeography\n",
- "\n",
- "3\tQuit\n",
- "\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter your Selection: 1\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Sports Question\n",
- "What University did NFL star Deon Sanders attend?\n",
- "1 \t University of Miami\n",
- "2 \t California State University\n",
- "3 \t Indiana University\n",
- "4 \t Florida State University\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter your selection :4\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Correct\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 3
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/C_Programming_for_the_Absolute_Beginner/Chapter6.ipynb b/C_Programming_for_the_Absolute_Beginner/Chapter6.ipynb
deleted file mode 100755
index bfb0065f..00000000
--- a/C_Programming_for_the_Absolute_Beginner/Chapter6.ipynb
+++ /dev/null
@@ -1,652 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:74348a5183e19ad7ac30f2bcfa88ff539f69c16e0607950b89f2f1031fc1e024"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 6 : Arrays"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 6.1, Page No 134"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "iArray=range(5)\n",
- "\n",
- "for x in range(5):\n",
- " iArray[x]=0"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 6.2, Page No 134"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "iArray=range(5)\n",
- "\n",
- "for x in range(5):\n",
- " iArray[x]=x\n",
- " \n",
- "for x in range(5):\n",
- " print \"The value of iArray index \"+str(x)+\"is \"+str(x)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of iArray index 0is 0\n",
- "The value of iArray index 1is 1\n",
- "The value of iArray index 2is 2\n",
- "The value of iArray index 3is 3\n",
- "The value of iArray index 4is 4\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 6.3, Page No 136"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "iIndex = -1\n",
- "iArray=range(5)\n",
- "\n",
- "for x in range(5):\n",
- " iArray[x]=(x+5)\n",
- "\n",
- "while (iIndex < 0 or iIndex >4):\n",
- " iIndex=int(raw_input(\"Enter a valid index (0-4): \"))\n",
- " \n",
- "print \"The value of index \"+str(iIndex)+\" is \"+str(iArray[iIndex])"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a valid index (0-4): 4\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of index 4 is 9\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 6.4, Page No 137"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "cArray = range(5)\n",
- "cName=\"Olivia\"\n",
- "\n",
- "print \"\\nCharacter array not initialized:\\n\"\n",
- "\n",
- "for x in range(5):\n",
- " print \"Element \"+str(x)+\"'s Contents are \",cArray[x]\n",
- "\n",
- "print \"\\nInitialized character array: \"\n",
- "for x in range(6):\n",
- " print cName[x],"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Character array not initialized:\n",
- "\n",
- "Element 0's Contents are 0\n",
- "Element 1's Contents are 1\n",
- "Element 2's Contents are 2\n",
- "Element 3's Contents are 3\n",
- "Element 4's Contents are 4\n",
- "\n",
- "Initialized character array: \n",
- "O l i v i a\n"
- ]
- }
- ],
- "prompt_number": 20
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 6.5, Page No 138"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "iFound = -1\n",
- "iArray=range(5)\n",
- "\n",
- "for x in range(5):\n",
- " iArray[x]=(x+x)\n",
- " \n",
- "iValue=int(raw_input(\"Enter value to search for: \"))\n",
- "\n",
- "for x in range(5):\n",
- " if (iArray[x]==iValue):\n",
- " iFound=x\n",
- " break\n",
- "\n",
- "if(iFound > -1):\n",
- " print \"I found your search value in element \",iFound\n",
- "else:\n",
- " print \"Sorry, your search value was not found\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter value to search for: 8\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "I found your search value in element 4\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 6.6, Page No 141"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "iTwoD=[[0 for j in range(3)]for i in range(3)]\n",
- "for x in range(3):\n",
- " for y in range(3):\n",
- " iTwoD[x][y]=(x+y)\n",
- "for x in range(3):\n",
- " for y in range(3):\n",
- " print \"iTwoD[\"+str(x)+\"][\"+str(y)+\"]=\",iTwoD[x][y]"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "iTwoD[0][0]= 0\n",
- "iTwoD[0][1]= 1\n",
- "iTwoD[0][2]= 2\n",
- "iTwoD[1][0]= 1\n",
- "iTwoD[1][1]= 2\n",
- "iTwoD[1][2]= 3\n",
- "iTwoD[2][0]= 2\n",
- "iTwoD[2][1]= 3\n",
- "iTwoD[2][2]= 4\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 6.7, Page No 143"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "iTwoD=[[1,2,3],[4,5,6],[7,8,9]]\n",
- "iFoundAt=[0,0]\n",
- "\n",
- "iValue=0\n",
- "iFound=0\n",
- "\n",
- "iValue=int(raw_input(\"Enter your search value: \"))\n",
- "\n",
- "for x in range(3):\n",
- " for y in range(3):\n",
- " if(iTwoD[x][y]==iValue):\n",
- " iFound=1\n",
- " iFoundAt[0]=x\n",
- " iFoundAt[1]=y\n",
- " break\n",
- " \n",
- "if (iFound==1):\n",
- " print \"Found value in iTwoD [\"+str(iFoundAt[0])+\"][\"+str(iFoundAt[1])+\"]\"\n",
- "else:\n",
- " print \"Value not found\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter your search value: 7\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Found value in iTwoD [2][0]\n"
- ]
- }
- ],
- "prompt_number": 17
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 6.8, Page No 145"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "board=range(9)\n",
- "cWhoWon=' '\n",
- "iCurrentPlayer=0\n",
- "\n",
- "def displayBoard():\n",
- " print \"\\n\\t|\\t|\\n\"\n",
- " print \"\\t|\\t|\\n\"\n",
- " print \"\"+str(board[0])+\"\\t|\"+str(board[1])+\"\\t|\"+str(board[2])+\"\\n\"\n",
- " print \"--------|-------|--------\\n\"\n",
- " print \"\"+str(board[3])+\"\\t|\"+str(board[4])+\"\\t|\"+str(board[5])+\"\\n\"\n",
- " print \"--------|-------|--------\\n\"\n",
- " print \"\\t|\\t|\\n\"\n",
- " print \"\"+str(board[6])+\"\\t|\"+str(board[7])+\"\\t|\"+str(board[8])+\"\\n\"\n",
- " print \"\\t|\\t|\\n\"\n",
- "\n",
- "def verifySelection(iSquare,iPlayer):\n",
- " if(board[iSquare-1]==' ' and (iPlayer==1 or iPlayer==0)):\n",
- " board[iSquare-1]='X'\n",
- " return 0\n",
- " elif(board[iSquare-1]==' ' and iPlayer==2):\n",
- " board[iSquare-1]='0'\n",
- " return 0\n",
- " else:\n",
- " return 1\n",
- " \n",
- "def checkForWin():\n",
- " global cWhoWon\n",
- " if(board[0]=='X' and board[1]=='X' and board[2]=='X'):\n",
- " cWhoWon='X'\n",
- " elif(board[3]=='X' and board[4]=='X' and board[5]=='X'):\n",
- " cWhoWon='X'\n",
- " elif(board[6]=='X' and board[7]=='X' and board[8]=='X'):\n",
- " cWhoWon='X'\n",
- " elif(board[0]=='X' and board[3]=='X' and board[6]=='X'):\n",
- " cWhoWon='X'\n",
- " elif(board[1]=='X' and board[4]=='X' and board[7]=='X'):\n",
- " cWhoWon='X'\n",
- " elif(board[2]=='X' and board[5]=='X' and board[8]=='X'):\n",
- " cWhoWon='X'\n",
- " elif(board[0]=='X' and board[5]=='X' and board[8]=='X'):\n",
- " cWhoWon='X'\n",
- " elif(board[2]=='X' and board[5]=='X' and board[6]=='X'):\n",
- " cWhoWon='X'\n",
- " elif(board[0]=='0' and board[1]=='0' and board[2]=='0'):\n",
- " cWhoWon='0'\n",
- " elif(board[3]=='0' and board[4]=='0' and board[5]=='0'):\n",
- " cWhoWon='0'\n",
- " elif(board[6]=='0' and board[7]=='0' and board[8]=='0'):\n",
- " cWhoWon='0'\n",
- " elif(board[0]=='0' and board[3]=='0' and board[6]=='0'):\n",
- " cWhoWon='0'\n",
- " elif(board[1]=='0' and board[4]=='0' and board[7]=='0'):\n",
- " cWhoWon='0'\n",
- " elif(board[2]=='0' and board[5]=='0' and board[8]=='0'):\n",
- " cWhoWon='0'\n",
- " elif(board[0]=='0' and board[5]=='0' and board[8]=='0'):\n",
- " cWhoWon='0'\n",
- " elif(board[2]=='0' and board[5]=='0' and board[6]=='0'):\n",
- " cWhoWon='0'\n",
- " \n",
- " if(cWhoWon!=' '):\n",
- " if(cWhoWon=='X'):\n",
- " print \"\\nX Wins!\\n\"\n",
- " return\n",
- " \n",
- " if(cWhoWon=='0'):\n",
- " print \"\\n0 Wins!\\n\"\n",
- " return\n",
- " else:\n",
- " return\n",
- " \n",
- " for x in range(9):\n",
- " if(board[x]!=' '):\n",
- " catTotal=catTotal+1\n",
- " \n",
- " if(catTotal==9):\n",
- " cWhoWon='C'\n",
- " print \"\\nCAT Game!\\n\"\n",
- " return\n",
- "iSquareNum=0\n",
- "\n",
- "for x in range(8):\n",
- " board[x]=' '\n",
- " \n",
- "displayBoard()\n",
- "\n",
- "while(cWhoWon==' '):\n",
- " print \"\\n\"+cWhoWon+\"\\n\"\n",
- " \n",
- " if(iCurrentPlayer==1 or iCurrentPlayer==0):\n",
- " print \"\\nPLAYER X\\n\"\n",
- " iSquareNum=int(raw_input(\"Enter an available square number (1-9): \"))\n",
- " \n",
- " if(verifySelection(iSquareNum,iCurrentPlayer)==1):\n",
- " iCurrentPlayer=1\n",
- " else:\n",
- " iCurrentPlayer=2\n",
- " else:\n",
- " print \"\\nPLAYER 0\\n\"\n",
- " iSquareNum=int(raw_input(\"Enter an available square number (1-9): \"))\n",
- " \n",
- " if(verifySelection(iSquareNum,iCurrentPlayer)==1):\n",
- " iCurrentPlayer=2\n",
- " else:\n",
- " iCurrentPlayer=1\n",
- " displayBoard()\n",
- " checkForWin()\n",
- " \n",
- " "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "\t|\t|\n",
- "\n",
- "\t|\t|\n",
- "\n",
- " \t| \t| \n",
- "\n",
- "--------|-------|--------\n",
- "\n",
- " \t| \t| \n",
- "\n",
- "--------|-------|--------\n",
- "\n",
- "\t|\t|\n",
- "\n",
- " \t| \t|8\n",
- "\n",
- "\t|\t|\n",
- "\n",
- "\n",
- " \n",
- "\n",
- "\n",
- "PLAYER X\n",
- "\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter an available square number (1-9): 1\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- " \n",
- "\n",
- "\n",
- "PLAYER 0\n",
- "\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter an available square number (1-9): 2\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "\t|\t|\n",
- "\n",
- "\t|\t|\n",
- "\n",
- "X\t|0\t| \n",
- "\n",
- "--------|-------|--------\n",
- "\n",
- " \t| \t| \n",
- "\n",
- "--------|-------|--------\n",
- "\n",
- "\t|\t|\n",
- "\n",
- " \t| \t|8\n",
- "\n",
- "\t|\t|\n",
- "\n",
- "\n",
- " \n",
- "\n",
- "\n",
- "PLAYER X\n",
- "\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter an available square number (1-9): 4\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- " \n",
- "\n",
- "\n",
- "PLAYER 0\n",
- "\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter an available square number (1-9): 3\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "\t|\t|\n",
- "\n",
- "\t|\t|\n",
- "\n",
- "X\t|0\t|0\n",
- "\n",
- "--------|-------|--------\n",
- "\n",
- "X\t| \t| \n",
- "\n",
- "--------|-------|--------\n",
- "\n",
- "\t|\t|\n",
- "\n",
- " \t| \t|8\n",
- "\n",
- "\t|\t|\n",
- "\n",
- "\n",
- " \n",
- "\n",
- "\n",
- "PLAYER X\n",
- "\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter an available square number (1-9): 7\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- " \n",
- "\n",
- "\n",
- "PLAYER 0\n",
- "\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter an available square number (1-9): 5\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "\t|\t|\n",
- "\n",
- "\t|\t|\n",
- "\n",
- "X\t|0\t|0\n",
- "\n",
- "--------|-------|--------\n",
- "\n",
- "X\t|0\t| \n",
- "\n",
- "--------|-------|--------\n",
- "\n",
- "\t|\t|\n",
- "\n",
- "X\t| \t|8\n",
- "\n",
- "\t|\t|\n",
- "\n",
- "\n",
- "X Wins!\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 1
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/C_Programming_for_the_Absolute_Beginner/Chapter7.ipynb b/C_Programming_for_the_Absolute_Beginner/Chapter7.ipynb
deleted file mode 100755
index c1085a33..00000000
--- a/C_Programming_for_the_Absolute_Beginner/Chapter7.ipynb
+++ /dev/null
@@ -1,582 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:be75d77e91d7005f064cd2c560347aec768e900f2e81ef47804d4b096bc083a6"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 7 : Pointers"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 7.1, Page No 157"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "x=5\n",
- "iPtr=id(x)\n",
- "iPtr=7"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 7.2, Page No 157"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "x=1\n",
- "iPtr=id(x)\n",
- "\n",
- "iPtr=5\n",
- "\n",
- "print \"\\n*iPtr = \"+str(iPtr)+\"\\n &x = \"+str(id(x))"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "*iPtr = 5\n",
- " &x = 20176608\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 7.3, Page No 158"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "x=5\n",
- "y=10\n",
- "iPtr=None\n",
- "\n",
- "print \"Pointer points to: \",iPtr\n",
- "iPtr=id(y)\n",
- "print \"Ptr now points to: \",iPtr\n",
- "x=iPtr\n",
- "print \"The value of x is now\",x\n",
- "iPtr=15\n",
- "print \"The value of y is now\",iPtr"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Pointer points to: None\n",
- "Ptr now points to: 20373108\n",
- "The value of x is now 20373108\n",
- "The value of y is now 15\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 7.4, Page No 159"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def addTwoNumbers(x,y):\n",
- " return x+y\n",
- "\n",
- "\n",
- "x=0\n",
- "y=0\n",
- "\n",
- "x=int(raw_input(\"Enter first number:\"))\n",
- "y=int(raw_input(\"Enter second number:\"))\n",
- "\n",
- "print \"Result is: \",addTwoNumbers(x,y)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter first number:10\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter second number:15\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Result is: 25\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 7.5, Page No 161"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def demoPassByValue(x):\n",
- " x+=5\n",
- " print \"The value of x is:\",x\n",
- "\n",
- "x=0\n",
- "x=int(raw_input(\"Enter a number:\"))\n",
- "demoPassByValue(x)\n",
- "print \"The original value of x did not change:\",x"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a number:5\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of x is: 10\n",
- "The original value of x did not change: 5\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 7.6, Page No 162"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def demoPassByReference(x):\n",
- " x+=5\n",
- " print \"The value of x is now\",x\n",
- "\n",
- "x=0\n",
- "x=int(raw_input(\"Enter a number:\"))\n",
- "demoPassByReference(x)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter a number:10\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of x is now 15\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 7.7, Page No 164"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "iArray=[1,2,3,4,5]\n",
- "iPtr=id(iArray)\n",
- "print \"Address of pointer: \",iPtr\n",
- "print \"First address of array: \",id(iArray[0])\n",
- "print \"Pointer points to: \",iArray[0]\n",
- "print \"First element of array contains\",iArray[0]"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Address of pointer: 28621960\n",
- "First address of array: 19652320\n",
- "Pointer points to: 1\n",
- "First element of array contains 1\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 7.8, Page No 165"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def nameLength(name):\n",
- " x=0\n",
- " while(name[x] != '\\0'):\n",
- " x+=1;\n",
- " return x\n",
- "aName='\\0'\n",
- "aName=raw_input(\"Enter your first name: \")\n",
- "aName=aName+'\\0'\n",
- "print \"Your first name contains\"\n",
- "print str(nameLength(aName))+\" characters\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter your first name: mehta\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Your first name contains\n",
- "5 characters\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 7.9, Page No 167"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def squareNumber(num):\n",
- " for x in range(3):\n",
- " num[x]=num[x]*num[x]\n",
- "\n",
- "iNumbers=[2,4,6]\n",
- "print \"The current array value are:\"\n",
- "\n",
- "for x in range(3):\n",
- " print iNumbers[x]\n",
- "\n",
- "print \"\\n\"\n",
- "\n",
- "squareNumber(iNumbers)\n",
- "\n",
- "print \"The modified array values are :\"\n",
- "\n",
- "for x in range(3):\n",
- " print iNumbers[x]\n",
- "\n",
- "print \"\\n\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The current array value are:\n",
- "2\n",
- "4\n",
- "6\n",
- "\n",
- "\n",
- "The modified array values are :\n",
- "4\n",
- "16\n",
- "36\n",
- "\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 7.10, Page No 168"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def printArgument(num):\n",
- " print \"Read only argument is: \",num\n",
- " \n",
- "iNumber=5\n",
- "printArgument(iNumber)\n",
- " "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Read only argument is: 5\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 7.11, Page No 169"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def printArray(num):\n",
- " for x in range(3):\n",
- " print num[x]\n",
- "\n",
- "iNumbers=[2,4,6]\n",
- "printArray(iNumbers)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "2\n",
- "4\n",
- "6\n"
- ]
- }
- ],
- "prompt_number": 12
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 7.12, Page No 170"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def modifyArray(num):\n",
- " for x in range(3):\n",
- " num[x]=num[x]*num[x]\n",
- " \n",
- "iNumbers=[2,4,6]\n",
- "modifyArray(iNumbers)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [],
- "prompt_number": 14
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 7.13, Page No 173"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import random\n",
- "def encrypt(sMessage,random):\n",
- " x=0\n",
- " while(sMessage[x]):\n",
- " sMessage+=str(random)\n",
- " x+=1\n",
- " x=0\n",
- " print \"Encrypted message is: \"\n",
- " \n",
- " while(sMessage[x]):\n",
- " print sMessage[x]\n",
- " x+=1\n",
- "\n",
- "def decrypt(sMessage,random):\n",
- " x=0\n",
- " while(sMessage[x]):\n",
- " sMessage[x]=sMessage[x]-str(random)\n",
- " x+=1\n",
- " x=0\n",
- " while(sMessage[x]):\n",
- " print sMessage[x]\n",
- " x+=1\n",
- " \n",
- "myString=range(21)\n",
- "iSelection=0\n",
- "iRand= (random.randint(1,4)%4)+1\n",
- "\n",
- "while(iSelection != 4):\n",
- " print \"\\n\\n1\\t Encrypt Clear Text\\n\"\n",
- " print \"2\\tDecrypt Cipher Text\\n\"\n",
- " print \"3\\tGenerate New Key\\n\"\n",
- " print \"4\\tQuit\\n\"\n",
- " iSelection=int(raw_input(\"\\nSelect a Cryptography Option: \"))\n",
- " \n",
- " if(iSelection ==1):\n",
- " myString=raw_input(\"\\nEnter one word as clear text to encrypt: \")\n",
- " encrypt(myString,iRand)\n",
- " break\n",
- " elif(iSelection==2):\n",
- " myString=raw_input(\"\\nEnter cipher text to decrypt: \")\n",
- " decrypt(myString,iRand)\n",
- " break\n",
- " elif(iSelection==3):\n",
- " iRand= (random.randrange(1,4,1)%4)+1\n",
- " print \"\\nNew Key Generated\\n\"\n",
- " break\n",
- " else:\n",
- " exit(0)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "\n",
- "1\t Encrypt Clear Text\n",
- "\n",
- "2\tDecrypt Cipher Text\n",
- "\n",
- "3\tGenerate New Key\n",
- "\n",
- "4\tQuit\n",
- "\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Select a Cryptography Option: 1\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Enter one word as clear text to encrypt: bhavin\n"
- ]
- }
- ]
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/C_Programming_for_the_Absolute_Beginner/Chapter8.ipynb b/C_Programming_for_the_Absolute_Beginner/Chapter8.ipynb
deleted file mode 100755
index bca914f3..00000000
--- a/C_Programming_for_the_Absolute_Beginner/Chapter8.ipynb
+++ /dev/null
@@ -1,703 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:2192643aa60481aa37dedf877c77d457bede1bb6978dcdba9008684a80b17ad1"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 8 Strings"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.1, Page No. 181"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "myString=\"MIKE\"\n",
- "print \"The pointer variable's value is: \", id(myString)\n",
- "print \"The pointer variable points to: \",myString\n",
- "print \"The memory locations for each character are::\"\n",
- "for x in range(0,4):\n",
- " print id(myString[x]),"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " The pointer variable's value is: 44562688\n",
- "The pointer variable points to: MIKE\n",
- "The memory locations for each character are::\n",
- "19548160 20083536 20086752 20285008\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.2, Page No.183"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "color=raw_input(\"Enter your favorite color: \")\n",
- "print \"You entered: \",color"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter your favorite color: Blue\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "You entered: Blue\n"
- ]
- }
- ],
- "prompt_number": 9
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.3, Page No.183"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "color=raw_input(\"Enter your favorite color: \")\n",
- "print \"You entered: \",color"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter your favorite color: Black\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "You entered: Black\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.4, Page No. 185"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "names = []\n",
- "names.append(\"Michael\")\n",
- "names.append(\"Sheila\")\n",
- "names.append(\"Spencer\")\n",
- "names.append(\"Hunter\")\n",
- "names.append(\"Kenya\")\n",
- "print \"\\nNames in pointer array of type char:\\n\"\n",
- "for i in range(5):\n",
- " print names[i]"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Names in pointer array of type char:\n",
- "\n",
- "Michael\n",
- "Sheila\n",
- "Spencer\n",
- "Hunter\n",
- "Kenya\n"
- ]
- }
- ],
- "prompt_number": 7
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.5, Page No.186"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "colors = []\n",
- "print \"Enter 3 colors: \"\n",
- "for i in range(3):\n",
- " colors.append(raw_input())\n",
- "print \"Your entered: \"\n",
- "for i in range(3):\n",
- " print colors[i]"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter 3 colors: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "blue\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "black\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "white\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Your entered: \n",
- "blue\n",
- "black\n",
- "white\n"
- ]
- }
- ],
- "prompt_number": 13
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.6, Page No.187"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "str1=\"123.79\"\n",
- "str2=\"55\"\n",
- "\n",
- "print \"String1 is:\\\"\",str1,\"\\\"\"\n",
- "print \"String2 is:\\\"\",str2,\"\\\"\"\n",
- "\n",
- "x=float(str1)\n",
- "y=int(str2)\n",
- "\n",
- "print \"String 1 converted to a float is \",round(x,2)\n",
- "print \"String 2 converted to an integer is \",y"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "String1 is:\" 123.79 \"\n",
- "String2 is:\" 55 \"\n",
- "String 1 converted to a float is 123.79\n",
- "String 2 converted to an integer is 55\n"
- ]
- }
- ],
- "prompt_number": 16
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.7, Page No.188"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "str1=\"37\"\n",
- "str2=\"20\"\n",
- "\n",
- "print \"String1 + String2 is \", str1+str2"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "String1 + String2 is 3720\n"
- ]
- }
- ],
- "prompt_number": 18
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.8, Page No. 189"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "str1=\"37\"\n",
- "str2=\"20\"\n",
- "iResult=int(str1)+int(str2)\n",
- "print \"String1 + String2 is \", iResult"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "String1 + String2 is 57\n"
- ]
- }
- ],
- "prompt_number": 19
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.9, Page No. 190"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "str1=\"Michael\"\n",
- "str2=\"Vine\"\n",
- "print \"The length of string1 is \",len(str1)\n",
- "print \"The length of string2 is \",len(str2)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The length of string1 is 7\n",
- "The length of string2 is 4\n"
- ]
- }
- ],
- "prompt_number": 20
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.10, Page No.191"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "def convertL(char):\n",
- " char=char.lower()\n",
- " print \"The first name converted to lower case is: \",char\n",
- "def convertU(char):\n",
- " char=char.upper()\n",
- " print \"The first name converted to Upper case is: \",char\n",
- "name1=\"Michael\"\n",
- "name2=\"Vine\"\n",
- "\n",
- "convertL(name1)\n",
- "convertU(name2)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The first name converted to lower case is: michael\n",
- "The first name converted to Upper case is: VINE\n"
- ]
- }
- ],
- "prompt_number": 32
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.11, Page No.193"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "str2=\"C Language\"\n",
- "str1=str2\n",
- "print \"String 1 now contains \", str1"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "String 1 now contains C Language\n"
- ]
- }
- ],
- "prompt_number": 33
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 8.12, Page No.194"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "str1=\"Computer Science \"\n",
- "str2=\"is applied mathematics\"\n",
- "print str1+str2"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Computer Science is applied mathematics\n"
- ]
- }
- ],
- "prompt_number": 34
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Exmaple 8.13, Page No.195"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "str1=\"A\"\n",
- "str2=\"A\"\n",
- "str3=\"!\"\n",
- "print str1\n",
- "print str2\n",
- "print str3\n",
- "if str1==str2:\n",
- " print \"Letter A is equal to letter A\"\n",
- "if str1>str3:\n",
- " print \"Letter A is greater than character !\"\n",
- "if str3<str1:\n",
- " print \"Character ! is greater than letter A\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "A\n",
- "A\n",
- "!\n",
- "Letter A is equal to letter A\n",
- "Letter A is greater than character !\n",
- "Character ! is greater than letter A\n"
- ]
- }
- ],
- "prompt_number": 39
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Exmaple 8.14, Page No.197"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "str1=\"Analyzing strings with with the strstr() function\"\n",
- "str2=\"ing\"\n",
- "str3=\"xyz\"\n",
- "\n",
- "print str1\n",
- "print str2\n",
- "print str3\n",
- "\n",
- "if((str1.find(str2))!=-1):\n",
- " print \"Str2 was found in str1\"\n",
- "else: \n",
- " print \"Str2 was not found in str1\"\n",
- "\n",
- "if((str1.find(str3))!=-1):\n",
- " print \"Str3 was found in str1\"\n",
- "else: \n",
- " print \"Str3 was not found in str1\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Analyzing strings with with the strstr() function\n",
- "ing\n",
- "xyz\n",
- "Str2 was found in str1\n",
- "Str3 was not found in str1\n"
- ]
- }
- ],
- "prompt_number": 44
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Exmaple 8.15, Page No.198"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import time\n",
- "import os\n",
- "from array import array\n",
- "\n",
- "\n",
- "def checkAnswer(string1,string2):\n",
- " for x in range(len(string2)):\n",
- " string2=string2.upper()\n",
- " if(set(string2).intersection(string1.split())):\n",
- " print \"Great job\"\n",
- " else :\n",
- " print \"Sorry no word found...\"\n",
- " \n",
- "starGame=[]\n",
- "starGame.append(\"ADELANGUAGEFERVZOPIBMOU\")\n",
- "starGame.append(\"ZBPOINTERSKLMLOOPMNOCOT\")\n",
- "starGame.append(\"PODSTRINGGDIWHIEEICERLS\")\n",
- "starGame.append(\"YVCPROGRAMMERWQKNULTHMD\")\n",
- "starGame.append(\"UKUNIXFIMWXIZEQZINPUTEX\")\n",
- "\n",
- "displayed=0\n",
- "startTime=0\n",
- "os.system('cls')\n",
- "print \"word find\"\n",
- "startTime=int(round(time.time()*1000))\n",
- "for x in range(0,5):\n",
- " while ((startTime+3)>int(round(time.time()*1000))):\n",
- " if displayed==0:\n",
- " print \"find a word in:\"\n",
- " print \"\",starGame[x]\n",
- " displayed=1\n",
- " os.system('cls')\n",
- " answer=raw_input(\"Enter word found:\")\n",
- " checkAnswer(starGame[x],answer)\n",
- " displayed=0\n",
- " startTime=int(round(time.time()*1000))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "word find\n",
- "find a word in:\n",
- " ADELANGUAGEFERVZOPIBMOU\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter word found:U\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Sorry no word found...\n",
- "find a word in:\n",
- " ZBPOINTERSKLMLOOPMNOCOT\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter word found:T\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Sorry no word found...\n",
- "find a word in:\n",
- " PODSTRINGGDIWHIEEICERLS\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter word found:S\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Sorry no word found...\n",
- "find a word in:\n",
- " YVCPROGRAMMERWQKNULTHMD\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter word found:YV\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Sorry no word found...\n",
- "find a word in:\n",
- " UKUNIXFIMWXIZEQZINPUTEX\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter word found:UKU\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Sorry no word found...\n"
- ]
- }
- ],
- "prompt_number": 1
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/C_Programming_for_the_Absolute_Beginner/Chapter9.ipynb b/C_Programming_for_the_Absolute_Beginner/Chapter9.ipynb
deleted file mode 100755
index 583e1e8f..00000000
--- a/C_Programming_for_the_Absolute_Beginner/Chapter9.ipynb
+++ /dev/null
@@ -1,549 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:c7a7a5fed3d237b23773c146200cb1c66c8b51b03326b1d931d288bf060c18a1"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 9 : Introduction to Data Structures"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.1, Page No 205"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "class employee:\n",
- " def __init__(self,fname,lname,id1,salary):\n",
- " self.fname = fname\n",
- " self.lname = lname\n",
- " self.id1 = id1\n",
- " self.salary = salary\n",
- "if __name__ == '__main__':\n",
- " emp1 = employee(\"Michael\",\"Vine\",123,50000.00)\n",
- " print \"\\n First name: \" + emp1.fname + \"\\n\"\n",
- " print \"Last name: \" + emp1.lname + \"\\n\"\n",
- " print \"Employee ID: \" + str(emp1.id1) + \"\\n\"\n",
- " print \"Salary: \" + str(emp1.salary) + \"\\n\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- " First name: Michael\n",
- "\n",
- "Last name: Vine\n",
- "\n",
- "Employee ID: 123\n",
- "\n",
- "Salary: 50000.0\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 2
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.2, Page No 206"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "class employee:\n",
- " def __init__(self,fname,lname,id1,salary):\n",
- " self.fname = fname\n",
- " self.lname = lname\n",
- " self.id1 = id1\n",
- " self.salary = salary\n",
- "if __name__ == '__main__':\n",
- " emp1 = employee(\"Michael\",\"Vine\",123,50000.00)\n",
- " print \"\\n First name: \" + emp1.fname + \"\\n\"\n",
- " print \"Last name: \" + emp1.lname + \"\\n\"\n",
- " print \"Employee ID: \" + str(emp1.id1) + \"\\n\"\n",
- " print \"Salary: \" + str(emp1.salary) + \"\\n\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- " First name: Michael\n",
- "\n",
- "Last name: Vine\n",
- "\n",
- "Employee ID: 123\n",
- "\n",
- "Salary: 50000.0\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.3, Page No 209"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "class scores:\n",
- " def __init__(self,name,score):\n",
- " self.name = name\n",
- " self.score = score\n",
- "if __name__ == '__main__':\n",
- " highScores = []\n",
- " highScores.append(scores(\"Hunter\",40768))\n",
- " highScores.append(scores(\"Kenya\",38568))\n",
- " highScores.append(scores(\"Apollo\",35985))\n",
- " for x in range(3):\n",
- " print \"\\n\" + highScores[x].name + \"\\t\" + str(highScores[x].score) + \"\\n\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Hunter\t40768\n",
- "\n",
- "\n",
- "Kenya\t38568\n",
- "\n",
- "\n",
- "Apollo\t35985\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.4, Page No 211"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "class employee:\n",
- " def __init__(self,id1,name,salary):\n",
- " self.id1 = id1\n",
- " self.name = name\n",
- " self.salary = salary\n",
- "def processEmp(emp1):\n",
- " emp1.id1 = 123\n",
- " emp1.name = \"Sheila\"\n",
- " emp1.salary = 65000.00\n",
- "if __name__ == '__main__':\n",
- " emp1 = employee(0,0,0)\n",
- " processEmp(emp1)\n",
- " print \"\\n Id : \" + str(emp1.id1) + \"\\n\"\n",
- " print \"Name : \" + emp1.name + \"\\n\"\n",
- " print \"Salary : \" + str(emp1.salary) + \"\\n\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- " Id : 123\n",
- "\n",
- "Name : Sheila\n",
- "\n",
- "Salary : 65000.0\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 3
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.5, Page No 212"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "class player:\n",
- " def __init__(self,name,score):\n",
- " self.name = name\n",
- " self.score = score\n",
- "if __name__ == '__main__':\n",
- " aPlayer = player(0,0)\n",
- " ptrPlayer = id(aPlayer)\n",
- " aPlayer.name = \"Pinball Wizard\"\n",
- " aPlayer.score = 1000000.00\n",
- " print \"\\nPlayer : \" + aPlayer.name + \"\\n\"\n",
- " print \"Score : \" + str(aPlayer.score)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Player : Pinball Wizard\n",
- "\n",
- "Score : 1000000.0\n"
- ]
- }
- ],
- "prompt_number": 5
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.6, Page No 213"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "class employee:\n",
- " def __init__(self,id1,name,salary):\n",
- " self.id1 = id1\n",
- " self.name = name\n",
- " self.salary = salary\n",
- "def processEmp(emp1):\n",
- " emp1.id1 = 123\n",
- " emp1.name = \"Sheila\"\n",
- " emp1.salary = 65000.00\n",
- "if __name__ == '__main__':\n",
- " emp1 = employee(0,0,0)\n",
- " ptrEmp = id(emp1)\n",
- " processEmp(emp1)\n",
- " print \"\\nId : \" + str(emp1.id1) + \"\\n\"\n",
- " print \"Name : \" + emp1.name + \"\\n\"\n",
- " print \"Salary : \" + str(emp1.salary) + \"\\n\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Id : 123\n",
- "\n",
- "Name : Sheila\n",
- "\n",
- "Salary : 65000.0\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.7, Page No 215"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "class employee:\n",
- " def __init__(self,id1,name,salary):\n",
- " self.id1 = id1\n",
- " self.name = name\n",
- " self.salary = salary\n",
- "def processEmp(emp1 = []):\n",
- " emp1.append(employee(123,\"Sheila\",65000.00))\n",
- " emp1.append(employee(234,\"Hunter\",28000.00))\n",
- " emp1.append(employee(456,\"Kenya\",48000.00))\n",
- " return emp1\n",
- "if __name__ == '__main__':\n",
- " emp1 = []\n",
- " emp1 = employee(0,0,0)\n",
- " emp1 = processEmp(emp1 = [])\n",
- " for x in range(3):\n",
- " print \"\\nId : \" + str(emp1[x].id1) + \"\\n\" \n",
- " print \"Name : \" + emp1[x].name + \"\\n\"\n",
- " print \"Salary : \" + str(emp1[x].salary)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Id : 123\n",
- "\n",
- "Name : Sheila\n",
- "\n",
- "Salary : 65000.0\n",
- "\n",
- "Id : 234\n",
- "\n",
- "Name : Hunter\n",
- "\n",
- "Salary : 28000.0\n",
- "\n",
- "Id : 456\n",
- "\n",
- "Name : Kenya\n",
- "\n",
- "Salary : 48000.0\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.8, Page No 217"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "class phonebook:\n",
- " def __init__(self,name,number,address):\n",
- " self.name = name\n",
- " self.number = number\n",
- " self.address = address\n",
- "class magazine:\n",
- " def __init__(self,name,author,isbn):\n",
- " self.name = name\n",
- " self.author = author\n",
- " self.isbn = isbn\n",
- "if __name__ == '__main__':\n",
- " aBook = phonebook(\"John\",123,\"John Smith\")\n",
- " aMagazine = magazine(\"C Programming\",\"Michael Vine\",1-59863-480-1)\n",
- " print \"\\nUnion Details\\n\"\n",
- " print \"Address for aBook.name: \" + str(id(aBook.name)) + \"\\n\"\n",
- " print \"Address for aBook.number: \", str(id(aBook.number)) + \"\\n\"\n",
- " print \"Address for aBook.address: \", str(id(aBook.address)) + \"\\n\"\n",
- " print \"\\nStructure Details\\n\"\n",
- " print \"Address for aMagazine.name: \", str(id(aMagazine.name)) + \"\\n\"\n",
- " print \"Address for aMagazine.author: \", str(id(aMagazine.author)) + \"\\n\"\n",
- " print \"Address for aMagazine.isbn: \", str(id(aMagazine.isbn)) + \"\\n\""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- " \n",
- "Union Details\n",
- "\n",
- "Address for aBook.name: 66178424\n",
- "\n",
- "Address for aBook.number: 30796656\n",
- "\n",
- "Address for aBook.address: 66151792\n",
- "\n",
- "\n",
- "Structure Details\n",
- "\n",
- "Address for aMagazine.name: 66151744\n",
- "\n",
- "Address for aMagazine.author: 66150976\n",
- "\n",
- "Address for aMagazine.isbn: 64689272\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 10
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.9, Page No 219"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "x = 12\n",
- "y = 5\n",
- "print \"\\nWithout Type-Casting\\n\"\n",
- "print \"12 \\\\ 5 = \" + str(x/y) + \"\\n\"\n",
- "print \"\\nWith Type-Casting\\n\"\n",
- "print \"12 \\\\ 5 = \" + str(float(x)/float(y)) + \"\\n\"\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Without Type-Casting\n",
- "\n",
- "12 \\ 5 = 2\n",
- "\n",
- "\n",
- "With Type-Casting\n",
- "\n",
- "12 \\ 5 = 2.4\n",
- "\n"
- ]
- }
- ],
- "prompt_number": 11
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.10, Page No 220"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "number = 86\n",
- "letter = 'M'\n",
- "print \"\\n86 type-casted to char is: \" + chr(number) + \"\\n\"\n",
- "print \"\\n'M' type-casted to int is: \" + str(ord(letter)) + \"\\n \""
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "86 type-casted to char is: V\n",
- "\n",
- "\n",
- "'M' type-casted to int is: 77\n",
- " \n"
- ]
- }
- ],
- "prompt_number": 6
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example 9.11, Page No 222"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "import random\n",
- "class dec:\n",
- " def __init__(self,type1,used,value):\n",
- " self.type1 = type1\n",
- " self.used = used\n",
- " self.value = value\n",
- "def shuffel(thisDeck):\n",
- " found = 0\n",
- " print \"\\nYour five cards are: \\n\\n\"\n",
- " while found < 5:\n",
- " #iRnd = random.randint(1, 100) % 51 when we use this it gives error out of range\n",
- " if thisDeck[iRnd].used == 'n':\n",
- " if thisDeck[iRnd].value == 12:\n",
- " print \"Ace of : \" + str(thisDeck[iRnd].type1) + \"\\n\"\n",
- " elif thisDeck[iRnd].value == 11:\n",
- " print \"King of : \" + str(thisDeck[iRnd].type1) + \"\\n\"\n",
- " elif thisDeck[iRnd].value == 10:\n",
- " print \"Queen of : \" + str(thisDeck[iRnd].type1) + \"\\n\"\n",
- " elif thisDeck[iRnd].value == 9:\n",
- " print \"Jack of : \" + str(thisDeck[iRnd].type1) + \"\\n\"\n",
- " else:\n",
- " print str(thisDeck[iRnd].value + 2) + \"of\"\n",
- " print str(thisDeck[iRnd].type1) + \"\\n\" \n",
- "if __name__ == '__main__':\n",
- " myDeck = []\n",
- " for x in range(3):\n",
- " for y in range(13):\n",
- " if x==0:\n",
- " myDeck.append(dec(\"dimonds\",\"y\",\"n\"))\n",
- " elif x==1:\n",
- " myDeck.append(dec(\"clubs\",\"y\",\"n\"))\n",
- " elif x==2:\n",
- " myDeck.append(dec(\"hearts\",\"y\",\"n\"))\n",
- " elif x==3:\n",
- " myDeck.append(dec(\"spades\",\"y\",\"n\"))\n",
- " shuffel(myDeck)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": []
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file
diff --git a/C_Programming_for_the_Absolute_Beginner/README.txt b/C_Programming_for_the_Absolute_Beginner/README.txt
deleted file mode 100755
index 9bf2614f..00000000
--- a/C_Programming_for_the_Absolute_Beginner/README.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-Contributed By: Bhavin Mehta
-Course: mca
-College/Institute/Organization: Shri Brahmanand Institute of Computer Science - Chaparda
-Department/Designation: Assistant Professor
-Book Title: C Programming for the Absolute Beginner
-Author: Michael Vine
-Publisher: Thomson Course Technology United States of America
-Year of publication: 2008
-Isbn: 1-59863-480-1
-Edition: 2nd edition \ No newline at end of file
diff --git a/C_Programming_for_the_Absolute_Beginner/screenshots/1.png b/C_Programming_for_the_Absolute_Beginner/screenshots/1.png
deleted file mode 100755
index 0fc6a70b..00000000
--- a/C_Programming_for_the_Absolute_Beginner/screenshots/1.png
+++ /dev/null
Binary files differ
diff --git a/C_Programming_for_the_Absolute_Beginner/screenshots/1_1.png b/C_Programming_for_the_Absolute_Beginner/screenshots/1_1.png
deleted file mode 100755
index 0fc6a70b..00000000
--- a/C_Programming_for_the_Absolute_Beginner/screenshots/1_1.png
+++ /dev/null
Binary files differ
diff --git a/C_Programming_for_the_Absolute_Beginner/screenshots/2.png b/C_Programming_for_the_Absolute_Beginner/screenshots/2.png
deleted file mode 100755
index 6ceba6dc..00000000
--- a/C_Programming_for_the_Absolute_Beginner/screenshots/2.png
+++ /dev/null
Binary files differ
diff --git a/C_Programming_for_the_Absolute_Beginner/screenshots/2_1.png b/C_Programming_for_the_Absolute_Beginner/screenshots/2_1.png
deleted file mode 100755
index 6ceba6dc..00000000
--- a/C_Programming_for_the_Absolute_Beginner/screenshots/2_1.png
+++ /dev/null
Binary files differ
diff --git a/C_Programming_for_the_Absolute_Beginner/screenshots/3.png b/C_Programming_for_the_Absolute_Beginner/screenshots/3.png
deleted file mode 100755
index 101cd93b..00000000
--- a/C_Programming_for_the_Absolute_Beginner/screenshots/3.png
+++ /dev/null
Binary files differ
diff --git a/C_Programming_for_the_Absolute_Beginner/screenshots/3_1.png b/C_Programming_for_the_Absolute_Beginner/screenshots/3_1.png
deleted file mode 100755
index 101cd93b..00000000
--- a/C_Programming_for_the_Absolute_Beginner/screenshots/3_1.png
+++ /dev/null
Binary files differ