Skip to content

Instantly share code, notes, and snippets.

@fayeip
Created September 8, 2014 07:33
Show Gist options
  • Save fayeip/f2c6057037103fcac17b to your computer and use it in GitHub Desktop.
Save fayeip/f2c6057037103fcac17b to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"worksheets": [
{
"cells": [
{
"metadata": {},
"cell_type": "heading",
"source": "Editing Markdown",
"level": 1
},
{
"metadata": {},
"cell_type": "markdown",
"source": "This is a line of \"markdown\" is which apparently is more humble than \"markup\". It allows us to provide some text describing what we are doing with our code. It doesn't look very nice when viewed using when you are in edit mode, but after you execute the cell containing the text it looks pretty. To make all of the text on the page look nice, select the menu item Cell > Run All.\n \nTo edit this text, doubleclick into the box containing the text when viewing it in the notebook server.\n\nSee https://help.github.com/articles/markdown-basics for details on the Markdown syntax."
},
{
"metadata": {},
"cell_type": "heading",
"source": "Adding a Subheading",
"level": 3
},
{
"metadata": {},
"cell_type": "markdown",
"source": "**Task 1.** Your first task is to add a subheading above this sentence and call it \"Adding a Subheading\". Look at the toolbar with the icons to see how to add a row. "
},
{
"metadata": {},
"cell_type": "heading",
"source": "Adding a Second Subheading",
"level": 3
},
{
"metadata": {},
"cell_type": "markdown",
"source": "**Task 2.** Your second task is to add another subheading above this called \"Adding a Second Subheading\" at the same level as the one above."
},
{
"metadata": {},
"cell_type": "markdown",
"source": "**Task 3** There are at least three things to love about python:\n\n* interpreted\n* great at processing strings\n* *It has an awesome name!*\n\nDo you like this example? I'm showing you italics and bulleted lists in one fell swoop!"
},
{
"metadata": {},
"cell_type": "heading",
"source": "Let's Write Some Code",
"level": 1
},
{
"metadata": {},
"cell_type": "markdown",
"source": "Now we are going to write some code. First move your mouse into the cell below and either hit Control-enter to execute it or click on the \"Go\" triangle in the control panel above to execute it. "
},
{
"metadata": {},
"cell_type": "code",
"input": "sentence = \"The School of Information is both UC Berkeley’s newest and its smallest school.\"\nsentence",
"prompt_number": 4,
"outputs": [
{
"output_type": "pyout",
"prompt_number": 4,
"metadata": {},
"text": "'The School of Information is both UC Berkeley\\xe2\\x80\\x99s newest and its smallest school.'"
}
],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "markdown",
"source": "**Task 4** Write a line of code below to convert this to a list of words by breaking on white space (spaces); call this list 'sent'."
},
{
"metadata": {},
"cell_type": "code",
"input": "sent = sentence.split()\nsent",
"prompt_number": 6,
"outputs": [
{
"output_type": "pyout",
"prompt_number": 6,
"metadata": {},
"text": "['The',\n 'School',\n 'of',\n 'Information',\n 'is',\n 'both',\n 'UC',\n 'Berkeley\\xe2\\x80\\x99s',\n 'newest',\n 'and',\n 'its',\n 'smallest',\n 'school.']"
}
],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "markdown",
"source": "**Task 5** Using python list splicing, create a new list called 'lasttwo' that contains just the last two items from this list and return the result."
},
{
"metadata": {},
"cell_type": "code",
"input": "lasttwo = sent[-2:]\nlasttwo\nlastthree = sent[-3:]\nlastthree",
"prompt_number": 8,
"outputs": [
{
"output_type": "pyout",
"prompt_number": 8,
"metadata": {},
"text": "['its', 'smallest', 'school.']"
}
],
"language": "python",
"trusted": true,
"collapsed": false
},
{
"metadata": {},
"cell_type": "markdown",
"source": "**Task 6** Now edit the line of code above and change it to splice out the last three words and assign to a variable called lastthree. Be sure to re-execute it and return the result. Note that you will not be creating a new input line below."
}
],
"metadata": {}
}
],
"metadata": {
"name": "",
"signature": "sha256:aa87a367101d2838ae4fd9b6bd2d9a234585f946818c5ff8f64255221e2dfa1b"
},
"nbformat": 3
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment