{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# EE16A: Homework 0\n", "## Getting to know iPython" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Part (a) \n", "Execute the following mystery drawing, then draw the same object yourself (by hand):" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "theta = np.linspace(0,2*np.pi, 1000)\n", "r = 0.7*np.cos(5*theta) + 1.0\n", "\n", "ax = plt.subplot(111, polar=True)\n", "ax.plot(theta, r, color='r', linewidth=3)\n", "ax.plot(theta, 0.3*np.ones(len(theta)), color='b', linewidth=3)\n", "ax.grid(False)\n", "ax.set_rmax(2)\n", "ax.xaxis.set_visible(False)\n", "ax.yaxis.set_visible(False)\n", "ax.spines['polar'].set_visible(False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Part (b) \n", "\n", "The following code takes the sum of integers 0...10 \n", "Modify it to take the sum of integers 0...112" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "total = 0\n", "i = 0\n", "while (i <= 10):\n", " total += i\n", " i += 1\n", "\n", "print(\"The sum is \" + str(total))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.4.3" } }, "nbformat": 4, "nbformat_minor": 0 }