{ "metadata": { "name": "", "signature": "sha256:14a04d6c85fd009c5a84b7216ded952d2f9efbdfd70e6aedbc14859dcb069b49" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Homework 0" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The goal of this homework is to practice the skills learned in Lecture 2. These skills will be essential for the rest of this course." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Before starting to work on this homework, **make a new folder** named ```submissions``` under ```spring-2015-homeworks\\ ```, copy the directory ```Homework-0\\ ``` in it and edit that copy." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's make sure that you placed everything in the correct folder" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import os\n", "error = False\n", "\n", "if os.path.basename(os.path.realpath('.')) != \"Homework-0\":\n", " print \"The name of the current directory should be 'Homework-0'\"\n", " error = True\n", " \n", "if os.path.basename(os.path.realpath('..')) != \"submissions\":\n", " print \"You should be working in the folder 'submissions'\"\n", " error = True\n", " \n", "if os.path.basename(os.path.realpath('../..')) != 'spring-2015-homeworks':\n", " print \"You copied the directory under the wrong folder. It should be under 'spring-2015-homeworks'\"\n", " error = True\n", "\n", "if not error:\n", " print \"You did everything correctly. Congrats!\"" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, assuming that everything is in their correct place, you should ``git add`` all the new directories/files and make your initial ```git commit```." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## This is a Markdown cell" ] }, { "cell_type": "code", "collapsed": false, "input": [ "# Insert and edit your own markdown cell *below*. Write your favorite quote" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "# This is a code cell. Try executing it.\n", "print \"hi\"" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Write a function that takes as argument a string and returns its 3-letter suffix. If the string is shorter than 3 letters, return the whole string" ] }, { "cell_type": "code", "collapsed": false, "input": [ "def suffix_3(string):\n", " \"\"\"\n", " Returns the 3-letter suffix.\n", " \n", " Parameters:\n", " string: str\n", " \n", " Returns:\n", " suffix: str\n", " If `string` is more than 3-letters long, `suffix` is its 3-letter suffix. Otherwise, `suffix` is the same as `string`.\n", " \"\"\"\n" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "code", "collapsed": false, "input": [ "print suffix_3(\"Hi!\")\n", "print suffix_3(\"Superb\")" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "When you finish with the above function, don't forget to ```add``` and ```commit``` to your local git repository." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's print the versions of some packages that we will be using in the future. If any of these packages are not present, you should ```conda install``` them later." ] }, { "cell_type": "code", "collapsed": false, "input": [ "import numpy\n", "print 'numpy:', numpy.__version__\n", "\n", "import scipy\n", "print 'scipy:', scipy.__version__\n", "\n", "import matplotlib\n", "print 'matplotlib:', matplotlib.__version__\n", "\n", "import sklearn\n", "print 'scikit-learn:', sklearn.__version__\n", "\n", "import pandas\n", "print 'pandas:', pandas.__version__" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Submitting" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, you can follow the submission guidelines from the lecture notes to push your changes to your Github fork." ] }, { "cell_type": "code", "collapsed": false, "input": [ "# Code for setting the style of the notebook\n", "from IPython.core.display import HTML\n", "def css_styling():\n", " styles = open(\"../../theme/custom.css\", \"r\").read()\n", " return HTML(styles)\n", "css_styling()" ], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }