{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Chapter 14: Graphics Using C" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 1, Page Number : GUC-4" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "\n", "a = int(raw_input(\"Enter the first number : \"))\n", "b = int(raw_input(\"Enter the second number : \"))\n", "\n", "if a > b:\n", " print a, \" IS THE BIGGEST NUMBER\"\n", "else:\n", " print b, \" IS THE BIGGEST NUMBER\"\n", " \n", " " ], "language": "python", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "stream": "stdout", "text": [ "Enter the first number : 5\n" ] }, { "name": "stdout", "output_type": "stream", "stream": "stdout", "text": [ "Enter the second number : 3\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "5 IS THE BIGGEST NUMBER\n" ] } ], "prompt_number": 7 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 2, Page Number : GUC-10" ] }, { "cell_type": "code", "collapsed": false, "input": [ "%pylab inline\n", "import pylab\n", "import matplotlib.pyplot as plt\n", "\n", "x1 = int(raw_input(\"Enter start point coordinate : \"))\n", "y1 = int(raw_input())\n", "\n", "x2 = int(raw_input(\"Enter end point coordinate : \"))\n", "y2 = int(raw_input())\n", "\n", "figure()\n", "pylab.plot([x1,y1],[x2,y2])" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stderr", "text": [ "WARNING: pylab import has clobbered these variables: ['pylab']\n", "`%pylab --no-import-all` prevents importing * from pylab and numpy\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "Populating the interactive namespace from numpy and matplotlib\n" ] }, { "name": "stdout", "output_type": "stream", "stream": "stdout", "text": [ "Enter start point coordinate : 50\n" ] }, { "name": "stdout", "output_type": "stream", "stream": "stdout", "text": [ "40\n" ] }, { "name": "stdout", "output_type": "stream", "stream": "stdout", "text": [ "Enter end point coordinate : 200\n" ] }, { "name": "stdout", "output_type": "stream", "stream": "stdout", "text": [ "180\n" ] }, { "metadata": {}, "output_type": "pyout", "prompt_number": 11, "text": [ "[<matplotlib.lines.Line2D at 0x82b1130>]" ] }, { "metadata": {}, "output_type": "display_data", "png": "iVBORw0KGgoAAAANSUhEUgAAAXgAAAEACAYAAAC57G0KAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFM9JREFUeJzt3X9M1OcBx/HPETCx0Q6STWyB9VIR9RTW65TWRrIjE7ss\nk2hJSHCzVOg/2qzZOrW1fzh/bTCdLnXBTZdiuuyPtqaJmG5a29FD17TDpcY6SSZtIUOsRKa2sC26\nybM/nOehB8edd/f99X4ll9Dv/fg+PG0f3zx3X/QZY4wAAK6TZfUAAADpwQIPAC7FAg8ALsUCDwAu\nxQIPAC7FAg8ALjXuAt/X16fKykrNnTtX8+bN0+7duyVJly5dUlVVlUpKSrRkyRJduXIl8pympibN\nnDlTs2fP1tGjR9M7egDAmHzjfQ7+woULunDhgh566CENDw/r61//ug4ePKj9+/fry1/+stavX6+f\n/exnunz5spqbm9XV1aUVK1boxIkT6u/v1+LFi3X27FllZfGDAgBk2rgr7/Tp0/XQQw9JkqZMmaI5\nc+aov79fhw4dUn19vSSpvr5eBw8elCS1tbWprq5OOTk58vv9Ki4uVmdnZ5q/BQBALBNO697eXp08\neVKPPPKIBgYGlJ+fL0nKz8/XwMCAJOn8+fMqLCyMPKewsFD9/f0pHjIAYCImtMAPDw+rpqZGL730\nkqZOnTrqPp/PJ5/PN+Zzx7sPAJA+2fEe8J///Ec1NTVauXKlli1bJulGtV+4cEHTp0/XZ599pmnT\npkmSCgoK1NfXF3nuuXPnVFBQcMdrFhcX65NPPknV9wAAnjBjxgx9/PHHE378uAVvjFFjY6MCgYB+\n8IMfRI5XV1frlVdekSS98sorkYW/urpar776qq5du6aenh51d3ervLz8jtf95JNPZIzhZox+/OMf\nWz4Gu9yYC+aCubh1++M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G1M+0L/A9/+EPt2LEjsohJ0sDAgPLz8yVJ+fn5GhgYSPcwbCHWXERrbW3Vtz3yuxpi\nzUVbW5sKCwtVVlZm4cgyL9ZcdHd369ixY3r00UcVCoX0l7/8xcIRZk6suWhubtaPfvQjffWrX9W6\ndes881Ouz+fT4sWLNX/+fP3mN7+RlPjamdYF/s0339S0adMUDAbv+JPoJp/P54lP2sSbi5/85Cea\nNGmSVqxYYcHoMivWXPzrX//ST3/6U23evDnyOC+8/z/Wfxf//e9/dfnyZX3wwQfasWOHamtrLRxl\nZow1F4lcWOkm7733nk6ePKnDhw+rpaVFx48fH3X/hNbOhD41n6ANGzaYwsJC4/f7zfTp080999xj\nvve975lZs2aZzz77zBhjzPnz582sWbPSOQxbiDUXK1euNMYYs3//fvPYY4+Zf//73xaPMjNizUVN\nTY2ZNm2a8fv9xu/3m+zsbPPAAw+YgYEBq4ebVmP9P/Ktb33LhMPhyONmzJhhBgcHLRxp+o01F2Nd\nWOklmzZtMj//+c8TXjvTusBHC4fD5jvf+Y4xxph169aZ5uZmY8yNq1+ff/75TA3DFqLn4vDhwyYQ\nCJiLFy9aPCprRM9FNL/fb/7xj39YMCLrRM/Fr3/9a7Nx40ZjjDF/+9vfTFFRkZVDy7jouQgGg5E/\n7N555x0zf/58K4eWEf/85z/NF198YYwxZnh42Dz22GPmrbfeSnjtzOjf6HTzx4kXXnhBtbW1evnl\nl+X3+/X6669nchiWM8ZE5uL73/++rl27pqqqKknSwoULtWfPHiuHl3Gxfsz0wrZdLDe/74aGBjU0\nNKi0tFSTJk3Sb3/7W4tHlnk352KsCyvdbGBgQMuXL5d0Y7vuu9/9rpYsWaL58+cntHZyoRMAuJSt\n/so+AEDqsMADgEuxwAOAS7HAA4BLscADgEuxwAOAS7HAA4BLscADgEv9D8TPhbcY8WPyAAAAAElF\nTkSuQmCC\n", "text": [ "<matplotlib.figure.Figure at 0x8136550>" ] } ], "prompt_number": 11 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 3, Page Number : GUC-11" ] }, { "cell_type": "code", "collapsed": false, "input": [ "%pylab\n", "#Tkinter package is used for graphics\n", "from matplotlib.patches import Rectangle\n", "from matplotlib.collections import PatchCollection\n", "\n", "e = Rectangle(xy=(35, -50), width=80, height=80)\n", "fig = plt.gcf()\n", "fig.gca().add_artist(e)\n", "#e.set_clip_box(ax.bbox)\n", "e.set_alpha(0.7)\n", "pylab.xlim([20, 50])\n", "pylab.ylim([-65, -35])\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Using matplotlib backend: Qt4Agg\n", "Populating the interactive namespace from numpy and matplotlib\n" ] }, { "output_type": "stream", "stream": "stderr", "text": [ "WARNING: pylab import has clobbered these variables: ['e']\n", "`%pylab --no-import-all` prevents importing * from pylab and numpy\n" ] }, { "metadata": {}, "output_type": "pyout", "prompt_number": 22, "text": [ "(-65, -35)" ] } ], "prompt_number": 22 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 4, Page Number : GUC-13" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import turtle\n", "turtle.speed(0)\n", "\n", "\n", "turtle.forward(200)\n", "turtle.left(120)\n", "turtle.forward(200)\n", "turtle.left(120)\n", "turtle.forward(200)\n", "turtle.left(180)\n" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 38 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 5, Page Number: GUC-17" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import turtle\n", "turtle.speed(0)\n", "\n", "\n", "turtle.forward(200)\n", "turtle.left(90)\n", "turtle.forward(100)\n", "turtle.left(90)\n", "turtle.forward(200)\n", "turtle.left(90)\n", "turtle.forward(100)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 39 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 6, Page Number : GUC-18" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import turtle\n", "turtle.speed(0)\n", "\n", "\n", "turtle.forward(200)\n", "turtle.left(90)\n", "turtle.forward(100)\n", "turtle.left(90)\n", "turtle.forward(200)\n", "turtle.left(90)\n", "turtle.forward(100)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 41 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 7: Page Number: GUC-22" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from turtle import*\n", "speed(0)\n", "i=0\n", "while i < 360:\n", " forward(1)\n", " left(1)\n", " i+=1" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 42 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 8, Page Number:GUC-24" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from turtle import*\n", "speed(0)\n", "i=0\n", "while i < 360:\n", " forward(3)\n", " left(3)\n", " i+=3\n", "\n", "penup()\n", "right(90)\n", "forward(50)\n", "left(90)\n", "forward(100)\n", "left(90)\n", "pendown()\n", "forward(200)\n", "left(90)\n", "forward(200)\n", "left(90)\n", "forward(200)\n", "left(90)\n", "forward(200)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 50 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 9, Page Number : GUC-25" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from turtle import*\n", "speed(0)\n", "i=0\n", "while i < 360:\n", " forward(3)\n", " left(1)\n", " i+=1\n" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 54 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 10, Page Number : GUC-26" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from turtle import*\n", "speed(0)\n", "\n", "left(90)\n", "forward(50)\n", "i=0\n", "while i < 180:\n", " forward(1)\n", " left(1)\n", " i+=1\n", " \n", "forward(150)\n", "left(90)\n", "forward(250)\n", "left(90)\n", "forward(100)\n", "left(90)\n", "forward(140)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 11, Page Number : GUC-28" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import numpy as np\n", "from matplotlib import pyplot as plt\n", "\n", "OX = [1,2,3,4]\n", "OY = [200,590,670,435]\n", "\n", "fig = plt.figure()\n", "\n", "width = .35\n", "ind = np.arange(len(OY))\n", "plt.bar(ind, OY)\n", "plt.xticks(ind + width / 2, OX)\n", "\n", "fig.autofmt_xdate()" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 12, Page Number : GUC-30" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from mpl_toolkits.mplot3d import Axes3D\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "\n", "fig = plt.figure()\n", "ax = fig.add_subplot(111, projection='3d')\n", "for c, z in zip(['r'], [200,590,670,435]):\n", " xs = np.arange(20)\n", " ys = np.random.rand(20)\n", " ax.bar(xs, ys, zs=z)\n", " \n", "ax.set_xlabel('X')\n", "ax.set_ylabel('Y')\n", "ax.set_zlabel('Z')\n", "\n", "plt.show()\n" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 17 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 13, Page Number : GUC-31" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from pylab import *\n", "\n", "# make a square figure and axes\n", "figure(1, figsize=(6,6))\n", "ax = axes([0.1, 0.1, 0.8, 0.8])\n", "\n", "# The slices will be ordered and plotted counter-clockwise.\n", "\n", "sales = [200, 590, 670, 435]\n", "explode=(0, 0.05, 0, 0)\n", "\n", "pie(sales, explode=explode,\n", " autopct='%1.1f%%', shadow=True, startangle=90)\n", " # The default startangle is 0, which would start\n", " # the Frogs slice on the x-axis. With startangle=90,\n", " # everything is rotated counter-clockwise by 90 degrees,\n", " # so the plotting starts on the positive y-axis.\n", "\n", "\n", "\n", "show()" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 19 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 14, Page Number : GUC-34" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "import turtle\n", "\n", "i=0\n", "while i < 360:\n", " turtle.forward(3)\n", " turtle.left(3)\n", " i+=3\n", " \n", "turtle.penup()\n", "turtle.forward(200)\n", "\n", "turtle.pendown()\n", "i=0\n", "while i < 360:\n", " turtle.forward(3)\n", " turtle.left(3)\n", " i+=3\n", " \n", "turtle.penup()\n", "turtle.forward(100)\n", "turtle.left(90)\n", "turtle.forward(50)\n", "turtle.pendown()\n", "turtle.forward(100)\n", "turtle.left(90)\n", "turtle.forward(400)\n", "turtle.left(90)\n", "turtle.forward(100)\n", "turtle.right(90)\n", "turtle.forward(100)\n", "turtle.right(90)\n", "turtle.forward(150)\n", "turtle.right(90)\n", "turtle.forward(100)\n", "turtle.left(90)\n", "turtle.forward(50)\n", "turtle.right(90)\n", "turtle.forward(400)\n", "turtle.right(90)\n", "turtle.forward(50)\n", "turtle.left(90)\n", "turtle.forward(50)\n", "turtle.right(90)\n", "turtle.forward(100)\n", "turtle.left(90)\n", "turtle.forward(100)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "\n" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 15 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }