#MSc Python
#Tutorial 1 - Debugging Functions & Things
## Department of Computing - Imperial College London ##
## Author: William Hunter ##

### Dear all - welcome to the functions lab.

### The three sections are split up into the Nando's suaces. We start with Garlic and Herb, moving onto Medium and then Hot. Naturally the problems get more challenging each time.

### If you sucesfully complete these problems, you will be able to debug python code and functions. And in the later sections, write them yourself!

### 

import matplotlib.pyplot as plt
import numpy as numpy
from matplotlib import colors

###
###
### MILD (GARLIC & HERB) ### 1-D SPACE
###
###
###

### Constants & Arrays etc. ###
constant_1 = 2.45
constant_2 = 10.0

#This is defining the number of steps our arrays / functions take in their calculations - upping the resolution is more computationally intensive but it increases the accuary! The number I have provided might not be right!!
resolution = 10**1

#This is the x-axis -> numbers from 1 to 10, with a spacing equal to the resolution
x = np.linspace(1, 10, resolution) #x-vals support vector

#Define the function
def y_function():
    y = x * np.exp(-x) + 0.5
    return y_function


#an empty array for y values - check the syntax...!
y_values = ()
#Run a for-loop to calcuate y values using the x-support vector values
#maybe I've indexed this wrong... can you fix it for me?
for i in range(len(x)):
    values = y_function(x[ii])
    y_values.append(values)
    
#checking the values
print y_values
    
#plotting the values
#here we use matplotlib as plt - can you edit this until the graph looks the same?
plt.figure(dpi = 100)
plt.title()
plt.xlabel('x')
plt.ylabel('y')
plt.plot(x, y_values, '--', color = 'blue')
plt.legend(loc = 'best')#legend location = best 
plt.show()

