{
"metadata": {
"name": "",
"signature": "sha256:4d3b23e730c80420389c82b2058b54de7ec3059daf7bf03c4d850c51d583878b"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
" Midterm"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This exam can be administered after the students have completed Codecademy and the tours and exercises through [Graphics](../../../Content/Graphics).\n",
"\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The questions on this midterm are simple programming exercises that you should be able to complete without too much trouble. There are 5 questions and you have 110 minutes, so budget 20 minutes per question, with 10 minutes left over to check your work and push it to github. Make sure you give yourself time to address each question. If you get stuck on one, take it as far as you can go, then move on to the others."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Instructions:** Create a notebook in your main repository directory called `Midterm`. Give it a heading 1 cell title **Midterm**. Answer the questions posed on this page in your notebook. \n",
"\n",
"**Allowed resources:** \n",
"\n",
"* You may re-use any code from the tours and exercises that we have done and any code that you have written for this course. \n",
"* You may consult any online resource (Google, Wikipedia, StackOverflow, etc.) for guidance or clarification, \n",
"* but you *must not copy someone else's code* and use it as your own.\n",
"\n",
"Save your notebook when you are done and be sure to push it to github before you leave."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Question 1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In Robert McCloskey\u2019s book *Make Way for Ducklings*, the names of the ducklings are Jack, Kack, Lack, Mack, Nack, Ouack, Pack, and Quack. This loop outputs these names in order:\n",
"\n",
" prefixes = 'JKLMNOPQ' \n",
" suffix = 'ack'\n",
" for letter in prefixes: \n",
" print letter + suffix\n",
"\n",
"The output is:\n",
"\n",
" Jack \n",
" Kack \n",
" Lack \n",
" Mack \n",
" Nack \n",
" Oack \n",
" Pack \n",
" Qack\n",
"\n",
"Of course, that\u2019s not quite right because \u201cOuack\u201d and \u201cQuack\u201d are misspelled. \n",
"\n",
"Modify the program to fix this error."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#Implement your solution here"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Question 2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Use `ipythonblocks` to create an 8x8 grid with the first initial of your last name embedded in it in a different color. Use slices and/or loops to set the values rather than setting each block by hand. Here is an example:\n",
"\n",
"
\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | |
\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | |
\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | |
\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | |
\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | |
\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | |
\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | |
\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |