Assignment 1 Feedback
Here are some general statistics and feedback for Assignment 1:
The average score was 92%. Good work!
Question 1
Almost all of you got full marks here. Those who did not -- check your code carefully and don't be so careless next time!
Question 2
Since I went over this in class and released the algorithm, I expected you guys to do well. The most common mistake was: for some reason some of you thought that the first term was "1", the second term was "4/1", the third term was "4/3", etc. Not too sure why you would think that, since "1" was not in the description at all.
Question 3
This question posed the most problems for people. Many of you apparently misunderstood the question. The idea is this:
- The first guess (let's call it g1) is x/2
- The second guess is calculated as g2 = (g1+x/g1)/2.
- The third guess is calculated as g3 = (g2+x/g2)/2.
The algorithm should therefore be:
- Ask the user for the value of x and n.
- Set the result (let's call it guess) to be equals to x/2.
- For i starting from 2 and continuing through n:
- Calculate the value of the ith version of guess and use it to update guess: guess = (guess + x/guess)/2.
- Print out the final value of guess
Other problems:
- Many of you are using variable names that don't mean anything -- such as a, b, c, d, etc. Even worse, some of you are naming your programs 1.py, 2.py, 3.py. Remember: Give your variables meaningful names! (We'll start taking off points next time!) Also, we always give you the program name in the specifications. Use that name!
- Some of you are still quite fond of redundant code, eg:
- x = x: Errr -- ok, so what's the point of doing this?
- y = -1*pi: Why not just do y = -pi? You can test it out in the Python interactive shell if you aren't sure whether Python will let you do that.
- y = -1*y: Same thing: why not just do y = -y?
- Some of you handed in non-compiling programs (forgetting to import the math library, retrieving from variables without assigning to them first, etc. Next time, non-compiling programs will get a zero.
- Late programs: Next time, you will get a zero. This time, we're halving the marks for your program.