In [55]:
my_var_list = ['a','b','c']

In [56]:
a,b,c = my_var_list #unpacking variables from a list

In [3]:
a


Out[3]:
'a'

In [4]:
b


Out[4]:
'b'

In [5]:
c


Out[5]:
'c'

In [57]:
a,b = my_var_list #have to account for all variables


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-57-31e0e116a600> in <module>()
----> 1 a,b = my_var_list #have to account for all variables

ValueError: too many values to unpack (expected 2)

An example of polynomial functions


In [52]:
my_list = [] #list of test values for our function
for i in range(-100,100):
    my_list.append(i*0.1)
print(my_list)


[-10.0, -9.9, -9.8, -9.700000000000001, -9.600000000000001, -9.5, -9.4, -9.3, -9.200000000000001, -9.1, -9.0, -8.9, -8.8, -8.700000000000001, -8.6, -8.5, -8.4, -8.3, -8.200000000000001, -8.1, -8.0, -7.9, -7.800000000000001, -7.7, -7.6000000000000005, -7.5, -7.4, -7.300000000000001, -7.2, -7.1000000000000005, -7.0, -6.9, -6.800000000000001, -6.7, -6.6000000000000005, -6.5, -6.4, -6.300000000000001, -6.2, -6.1000000000000005, -6.0, -5.9, -5.800000000000001, -5.7, -5.6000000000000005, -5.5, -5.4, -5.300000000000001, -5.2, -5.1000000000000005, -5.0, -4.9, -4.800000000000001, -4.7, -4.6000000000000005, -4.5, -4.4, -4.3, -4.2, -4.1000000000000005, -4.0, -3.9000000000000004, -3.8000000000000003, -3.7, -3.6, -3.5, -3.4000000000000004, -3.3000000000000003, -3.2, -3.1, -3.0, -2.9000000000000004, -2.8000000000000003, -2.7, -2.6, -2.5, -2.4000000000000004, -2.3000000000000003, -2.2, -2.1, -2.0, -1.9000000000000001, -1.8, -1.7000000000000002, -1.6, -1.5, -1.4000000000000001, -1.3, -1.2000000000000002, -1.1, -1.0, -0.9, -0.8, -0.7000000000000001, -0.6000000000000001, -0.5, -0.4, -0.30000000000000004, -0.2, -0.1, 0.0, 0.1, 0.2, 0.30000000000000004, 0.4, 0.5, 0.6000000000000001, 0.7000000000000001, 0.8, 0.9, 1.0, 1.1, 1.2000000000000002, 1.3, 1.4000000000000001, 1.5, 1.6, 1.7000000000000002, 1.8, 1.9000000000000001, 2.0, 2.1, 2.2, 2.3000000000000003, 2.4000000000000004, 2.5, 2.6, 2.7, 2.8000000000000003, 2.9000000000000004, 3.0, 3.1, 3.2, 3.3000000000000003, 3.4000000000000004, 3.5, 3.6, 3.7, 3.8000000000000003, 3.9000000000000004, 4.0, 4.1000000000000005, 4.2, 4.3, 4.4, 4.5, 4.6000000000000005, 4.7, 4.800000000000001, 4.9, 5.0, 5.1000000000000005, 5.2, 5.300000000000001, 5.4, 5.5, 5.6000000000000005, 5.7, 5.800000000000001, 5.9, 6.0, 6.1000000000000005, 6.2, 6.300000000000001, 6.4, 6.5, 6.6000000000000005, 6.7, 6.800000000000001, 6.9, 7.0, 7.1000000000000005, 7.2, 7.300000000000001, 7.4, 7.5, 7.6000000000000005, 7.7, 7.800000000000001, 7.9, 8.0, 8.1, 8.200000000000001, 8.3, 8.4, 8.5, 8.6, 8.700000000000001, 8.8, 8.9, 9.0, 9.1, 9.200000000000001, 9.3, 9.4, 9.5, 9.600000000000001, 9.700000000000001, 9.8, 9.9]

In [10]:
import matplotlib.pyplot as plt

In [11]:
%matplotlib inline

In [64]:
plt.figure(figsize=(10,10))
plt.ylim(-10,10)
plt.axhline(0, color='black')
plt.axvline(0, color='black')
plt.plot(my_list,my_list,label="Linear")
plt.plot(my_list,list(map(lambda x: x**2, my_list)),label="2nd degree")
plt.plot(my_list,list(map(lambda x: x**3, my_list)),label="3rd degree")
plt.plot(my_list,list(map(lambda x: x**4, my_list)),label="4th degree")
plt.plot(my_list,list(map(lambda x: x**5, my_list)),label="5th degree")
plt.plot(my_list,list(map(lambda x: x**6, my_list)),label="6th degree")
plt.plot(my_list,list(map(lambda x: x**7, my_list)),label="7th degree")
plt.plot(my_list,list(map(lambda x: x**8, my_list)),label="8th degree")
plt.plot(my_list,list(map(lambda x: x**9, my_list)),label="9th degree")
plt.plot(my_list,list(map(lambda x: x**10, my_list)),label="10th degree")
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)


Out[64]:
<matplotlib.legend.Legend at 0x7fd194e582b0>

In [ ]: