<div>Dear tutor, </div>  <div>&nbsp;&nbsp;&nbsp;&nbsp; I have a question regarding a functions based assignment. The assignment is:</div>  <div>For this project, you will write two small Python programs: </div>  <div></div>  <OL>  <LI><B>Investment Thresholds</B>   <div></div>  <OL>  <LI>Define a Python function <CODE>threshold(dailyGains, goal)</CODE> that behaves as follows. The first parameter is a list of integers that represent the daily gains in the value of a stock. The second paramter is a single positive number that is a profit goal. The function should return the minimum number of days for which the stock should be owned in order to achieve a profit that is equal to or greater than the stated goal. If the goal is unreachable, the function should return 0.   <div></div>For example,   <div></div><CODE>threshold ([5, 3, 8, 2, 9, 1], 17)</CODE>   <div></div>should return 4 because the goal (17) can be reached after the first four days (e.g., 5 + 3 + 8 + 2).  
 <div></div>  <LI>Write a small Python program that uses your <CODE>threshold()</CODE> function to demonstrate that it works correctly. Your program may use a pre-defined list of stock gains or it may generate one randomly (see the "Helpful Hints" section below for tips on how to do this). Your program should display this list, prompt the user to enter a profit goal, and then print out the total number of days required to reach that goal (or a message stating that the goal is impossible).   <div></div></LI></OL>  <div></div>  <LI><B>Word Windows</B>   <div></div>  <OL>  <LI>Define a Python function <CODE>sliding(word, num)</CODE> that behaves as follows. It should print out each <CODE>num</CODE>-length slice of the original <CODE>word</CODE> , aligned vertically as shown below.   <div></div>For example, a call to <CODE>sliding("examples", 4)</CODE> should produce the output   <div></div><PRE>exam   xamp    ampl     mple      ples      </PRE>  <div></div>  <LI>Write a small
 Python program to demonstrate that your <CODE>sliding()</CODE> function works correctly. Your program should prompt the user to enter a word and a window size, and then call <CODE>sliding()</CODE> with those values.   <div></div></LI></OL></LI></OL>  <div></div>  <H2>Helpful Hints</H2>  <div>  <UL>  <LI>Python contains a set of facilities to handle random number generation. Full details are available at <A href="http://docs.python.org/lib/module-random.html">http://docs.python.org/lib/module-random.html</A>. A quick summary is as follows:   <div></div>  <OL>  <LI>Add the statement   <div></div><CODE>import random</CODE>   <div></div>at the beginning of your program source code. This tells Python where to find the code that describes how to generate random values.   <div></div>  <LI>Pass your list of values to the <CODE>random.choice()</CODE> function. The function will return a single randomly-selected element from that list.   <div></div>For example,
 <CODE>random.choice(range(5))</CODE> will return a random value in the range 0-4.   <div></div>Please note that "random" <I>does not necessarily mean</I> "unique"; sequential calls to this function may return the same answer, because it is randomly chosen each time! </LI></OL></LI></UL>  <div>&nbsp; </div>  <div>This is what I have so far:</div>  <div>&nbsp;</div>  <div>import random<BR>dailyGains = int(random.range(6))<BR>goal = random.choice(range(4)<BR>result = []<BR>def threshold(dailyGains, goal):<BR>&nbsp; if goal!= result: 0<BR>&nbsp; else:<BR>&nbsp;&nbsp;&nbsp; result.reverse()<BR>&nbsp;&nbsp;&nbsp; result.remove()</div>  <div>&nbsp;</div>  <div>As you can see I am having a great problem.<BR></div><p>&#32;
      <hr size=1>Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile. <a href="http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ "> Try it now.</a>