Assignment A

Notebook

In JupyterLab, choose File > New > Notebook.

Select File > Save Notebook As… and save your notebook in a location that you can easily find. Suggested file name: Python Assignment A.ipynb

Create Plot

Type a title, your name and today’s date in the first cell, like this:

## Assignment A
Your Name\
YYYY-MM-DD

Select cell type Markdown for this cell from the drop down menu at the top of your notebook.

Run the cell by clicking the Run (“play”) button.

Insert a new cell by clicking the Insert (+) button.

Transform the initials of your name into two numbers by their order in the alphabet, 1 for A, 2 for B, 3 for C, etc. For example, if your name is Jane Doe, your two numbers would be 10 and 4. Then, replace the constants 10 and 4 in the function \(f(x)=10\cdot\sqrt{\mid x \mid}+\frac{\sin(4\cdot x)}{e^{x}}\) with your two numbers and plot the function.

Your code should look like this (except for the two constants):

import numpy as np
import matplotlib.pyplot as plt

def f(x):
    return 10*np.sqrt(np.abs(x)) + np.sin(4*x)/np.exp(x) 

x = np.linspace(-3, 3, 400)
y = f(x)

plt.plot(x, y)
plt.ylim(min(y)-1, max(y)+1)
plt.show()

Study the above code and try to understand what each line means.

Hand In

Choose File > Print… and save your document as a PDF-file. The final PDF-document should be one single page and show the title, your name, today’s date and the plot. E-mail the PDF-document to for review. As e-mail subject, write Python Assignment A.