{
 "metadata": {
  "name": "",
  "signature": "sha256:995bd55986cb75ede34cceda310ffd2c9f00a5c6e6a22d85c294456d1db3fd3f"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 10: Interfaces: Multiple Inheritance"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 10.1, page no. page no. 184"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\"\"\"\n",
      "There are no interfaces in Python. We will use normal classes instead\n",
      "\"\"\"\n",
      "\n",
      "class Rectangle:\n",
      "    def compute(self, x, y):\n",
      "        return x*y\n",
      "\n",
      "class Circle:\n",
      "    pi = 3.14\n",
      "    def compute(self, x, y):\n",
      "        return self.pi*x*x\n",
      "\n",
      "rect = Rectangle()\n",
      "cir = Circle()\n",
      "print \"Area of rectangle: \", rect.compute(10, 20)\n",
      "print \"Area of circle: \", cir.compute(10, 0)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Area of rectangle:  200\n",
        "Area of circle:  314.0\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "example 10.2, page no. 211"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "class Student(object):\n",
      "    rollNumber = 0\n",
      "    def getNumber(self, n):\n",
      "        self.rollNumber = n\n",
      "    def putNumber(self):\n",
      "        print \"Roll No.: \", self.rollNumber\n",
      "\n",
      "class Test(Student, object):\n",
      "    part1 = 0.0\n",
      "    part2 = 0.0\n",
      "    def getMarks(self, m1, m2):\n",
      "        self.part1 = m1\n",
      "        self.part2 = m2\n",
      "    def putMarks(self):\n",
      "        print \"Marks Obtained\"\n",
      "        print \"Part 1  = \", self.part1\n",
      "        print \"Part 2 = \", self.part2\n",
      "\n",
      "class Results(Test):\n",
      "    sportWt = 6.0\n",
      "    def putWt(self):\n",
      "        print \"Sports Wt: \", self.sportWt\n",
      "    def display(self):\n",
      "        total = self.part1 + self.part2 + self.sportWt\n",
      "        self.putNumber()\n",
      "        self.putMarks()\n",
      "        self.putWt()\n",
      "        print \"Total Score: \", total\n",
      "\n",
      "student1 = Results()\n",
      "student1.getNumber(1234)\n",
      "student1.getMarks(27.5, 33.0)\n",
      "student1.display()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Roll No.:  1234\n",
        "Marks Obtained\n",
        "Part 1  =  27.5\n",
        "Part 2 =  33.0\n",
        "Sports Wt:  6.0\n",
        "Total Score:  66.5\n"
       ]
      }
     ],
     "prompt_number": 9
    }
   ],
   "metadata": {}
  }
 ]
}