{ "metadata": { "name": "", "signature": "sha256:accfa65c82343aeed5f184613989e8f303b6335bf19049dd322738d1012e1aff" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Chapter 1 : Getting Started" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 1.1, Page No 12" ] }, { "cell_type": "code", "collapsed": false, "input": [ "print \"Hello World!\"" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Hello World!\n" ] } ], "prompt_number": 1 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 1.2, Page No 17" ] }, { "cell_type": "code", "collapsed": false, "input": [ "letter = 'A'\n", "number = 100\n", "decimal = 7.5\n", "pi = 3.14159\n", "isTrue = \"false\"\n", "print \"char letter: \",letter\n", "print \"int number: \",number\n", "print \"float decimal: \",decimal\n", "print \"double pi: \",pi\n", "print \"bool isTrue: \",isTrue" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "char letter: A\n", "int number: 100\n", "float decimal: 7.5\n", "double pi: 3.14159\n", "bool isTrue: false\n" ] } ], "prompt_number": 4 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 1.3, Page No 19" ] }, { "cell_type": "code", "collapsed": false, "input": [ "nums = [1.5,2.75,3.25]\n", "name = ['m','i','k','e','\\0']\n", "coords = [(1,2,3),(4,5,6)]\n", "print \"nums[0]: \",nums[0]\n", "print \"nums[1]: \",nums[1]\n", "print \"nums[2]: \",nums[2]\n", "print \"name[0]: \",name[0]\n", "print \"Test stirng: \", \"\".join(name)\n", "print \"coords[0][2]: \",coords[0][2]\n", "print \"coords[1][2]: \",coords[1][2]" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "nums[0]: 1.5\n", "nums[1]: 2.75\n", "nums[2]: 3.25\n", "name[0]: m\n", "Test stirng: mike\u0000\n", "coords[0][2]: 3\n", "coords[1][2]: 6\n" ] } ], "prompt_number": 24 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 1.4, Page No 21" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# ipython does not support vector array" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 14 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 1.5, Page No 23" ] }, { "cell_type": "code", "collapsed": false, "input": [ "PI = 3.1415926536\n", "print \"6\\\" circle circumference: \" ,(PI * 6)\n", "#ENUM IS NOT IN PYTHON SO DECLARED DIRECTLY\n", "RED = 1\n", "YELLOW = 2\n", "GREEN = 3\n", "BROWN = 4\n", "BLUE = 5\n", "PINK = 5\n", "BLACK = 6\n", "print \"I shot a red worth: \",RED\n", "print \"Then a blue worth: \",BLUE\n", "print \"Total scored: \",(RED+BLUE)\n", "#typedef and enum is not in python so declared directly\n", "neutral = \"NEGATIVE \"\n", "live = \"POSITIVE\"\n", "print \"Neutral wire: \", neutral\n", "print \"Live wire: \", live" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "6\" circle circumference: 18.8495559216\n", "I shot a red worth: 1\n", "Then a blue worth: 5\n", "Total scored: 6\n", "Neutral wire: NEGATIVE \n", "Live wire: POSITIVE\n" ] } ], "prompt_number": 19 } ], "metadata": {} } ] }