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.
Before starting to work on this homework, make a new folder named
spring-2015-homeworks\, copy the directory
Homework-0\ in it and edit that copy.
Let's make sure that you placed everything in the correct folder
In [ ]:import os error = False if os.path.basename(os.path.realpath('.')) != "Homework-0": print "The name of the current directory should be 'Homework-0'" error = True if os.path.basename(os.path.realpath('..')) != "submissions": print "You should be working in the folder 'submissions'" error = True if os.path.basename(os.path.realpath('../..')) != 'spring-2015-homeworks': print "You copied the directory under the wrong folder. It should be under 'spring-2015-homeworks'" error = True if not error: print "You did everything correctly. Congrats!"
Now, assuming that everything is in their correct place, you should
git add all the new directories/files and make your initial
In [ ]:# Insert and edit your own markdown cell *below*. Write your favorite quote
In [ ]:# This is a code cell. Try executing it. print "hi"
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
In [ ]:def suffix_3(string): """ Returns the 3-letter suffix. Parameters: string: str Returns: suffix: str If `string` is more than 3-letters long, `suffix` is its 3-letter suffix. Otherwise, `suffix` is the same as `string`. """
In [ ]:print suffix_3("Hi!") print suffix_3("Superb")
When you finish with the above function, don't forget to
commit to your local git repository.
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.
In [ ]:import numpy print 'numpy:', numpy.__version__ import scipy print 'scipy:', scipy.__version__ import matplotlib print 'matplotlib:', matplotlib.__version__ import sklearn print 'scikit-learn:', sklearn.__version__ import pandas print 'pandas:', pandas.__version__
Now, you can follow the submission guidelines from the lecture notes to push your changes to your Github fork.
In [ ]:# Code for setting the style of the notebook from IPython.core.display import HTML def css_styling(): styles = open("../../theme/custom.css", "r").read() return HTML(styles) css_styling()