- \n",
"
- To help you learn some Python essentials and programming skills to enjoy this module.\n", "

- \n",
"
- Complete the notebook below, as follows. Click on a question, then from the menu select Insert -> Insert Cell Below. From the dropdown box (next to the \"stop\" symbol) choose whether you wish to insert 'Code' or 'Markdown'. Save regularly! \n", " \n", "
- Press Shift-Enter to execute the code in a cell.\n", "\n", "
- Submit the .ipynb file via https://somas-uploads.shef.ac.uk/mas212 by 23.59pm on Sun 13th Oct 2019.
*If you are off-campus, you will need to use a VPN to submit.*\n", "\n", " - Your lecturer will mark each question as either 2 (good), 1 (needs revision), 0 (not attempted/wrong).\n", "\n", "
- This is an open-book test, which means you may consult books, notes and internet resources.
**Do not discuss or share your test with anyone**. Copy-and-pasting is**not permitted**.*Please give answers in your own words.*\n", " \n", " - Some of these questions are relatively straightforward, and some are harder (e.g. Q20). Please don't spend any longer than a maximum of 4 hours on this test, as it is for a relatively small amount of credit.\n", "

- \n",
"
- Lecture materials and links on course web page: http://sam-dolan.staff.shef.ac.uk/mas212/\n", "

\n", "

`list`

and `set`

data types."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`string`

is similar to a `list`

, and one way in which it is different."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n", "(i) In Python, function arguments are passed

\n", "(ii) Function arguments can be modified within functions." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

\n", " What is the shape of A*B, if the arrays A and B have shapes (7,3,1) and (3,7,1,4)?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

\n", "

\n", "[N.B. The Fibonacci sequence is defined by $f_{k+1} = f_k + f_{k-1}$ with $f_{0} = f_{1} = 1$. The Golden Ratio is $\\frac{1}{2}(\\sqrt{5} + 1)$.]

`expfn(x)`

to calculate $e^x$ by truncating the series expansion \n",
" $$\n",
" e^x = \\sum^{}_{n=0} \\frac{x^n}{n!} \n",
" $$ at $n_{max} = 10$.\n", " Test your function by calculating $e^{i \\pi}$. How accurate is the result?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

`\"me.txt\"`

.\n", "

`s`

?`s`

, and how many characters does it have?\n", "

`numpy`

`np.linalg`

, find the eigenvalues of the real symmetric matrix\n",
"$$\n",
"A = \\begin{bmatrix} 1 & 2 & 3 \\\\ 2 & 4 & 1 \\\\ 3 & 1 & -5 \\end{bmatrix} .\n",
"$$\n",
"Verify that the sum of the eigenvalues is zero.\n",
"\n", "

`ciphertext`

using `keytext`

, to recover the melody as a string of letters, A to G.From what piece of music is this melody taken? (