{ "metadata": { "name": "", "signature": "sha256:85fd10a5846b5256e76a45973450cd001c1aeb110532e77b6ab379820dba7274" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Chapter 1 : Overview" ] }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 1.1 Page No : 17" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "\n", "class BankAccount:\n", " def __init__(self,openingBalance): # constructor\n", " self.balance = openingBalance\n", "\n", " def deposit(self,amount): # makes deposit\n", " self.balance = self.balance + amount; \n", " \n", " def withdraw(self,amount): # makes withdrawal\n", " self.balance = self.balance - amount; \n", "\n", " def display(self):\n", " # displays balance \n", " print 'balance=' , self.balance\n", "\n", "# end class BankAccount\n", "\n", "ba1 = BankAccount(100.00) # create acct\n", "print 'Before transactions, ',\n", "ba1.display()\n", "# display balance\n", "ba1.deposit(74.35)\n", "ba1.withdraw(20.00)\n", "print 'After transactions, ' ,\n", "ba1.display()" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Before transactions, balance= 100.0\n", "After transactions, balance= 154.35\n" ] } ], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }