timc09/CS112-Spring2012 — comment on commit c0397f4d9b5b4f7eda687c727b7bd300c9451367
File:  line 0
By alecgoebel:

Homework 3
===========

| **Part** | **Points** |
|-----------|------------|
| base | 1 |
| advanced | 1 |
| clean code | 0.25 |
| if/while statements | 0.25 |
| function/recursion | 0.25 |
| **Total** | 2.75 |

First off, I like your file names. I didn't think that would be something I'd notice in homeworks but after weird camelcaps/capitalized/everything it's nice to see short lowercase filenames.

Great job overall on this assignment. That said you have been programming for a while now so I guess it should be expected that you picked up if and while on your own. If at any point going forward the homeworks are still too easy to you after we do functions, let me know and I'll try to find some thing you can challenge yourself with (for "credit" of course).

## prissybot.py
Well done on this program. Step one was perfect and you met everything for step 2. Also, kudos for reusing variables. Just some quick comments on formating for the future:

```python
## print statements should have a space between print and the string

print"hi" # bad
print "Hello!" #good
```

```python
## long comments should go before the line
# original
if float(in1)%float(in2)!=0:#checks to see if the math apeared strange due to integer math
print"Ha! Integer math."#if so, prissybot comments on it

# cleaner

# comments if the math appeared strange due to integer math
if float(in1) % float(in2) != 0:
print "Ha! Integer math."
```

```python
## end of line comments should have some space between the code and comment

# cramped
a=0#reset a

# open
a = 0 # reset a
```

## ascii.py
I like the lightning bolt. I'll have to remember it for the future as a good follow up to the diamond example. There isn't much to comment on in the code other than the comments themselves. Mainly that there seems to be a lot of them. If these are for yourself than keep them in. If they are for the TAs you should try to be a bit more succinct. For example, I am familiar with why you use `print ""` and don't necessarily need it documented.

Also, there is almost never a reason to combine string substitution with concatenation. Your print statements could be just as easily be written as:

```python
print "%s % c*(17-i)
print " %s % c*(17-i)
print " %s % c*(17-i)
```

Lastly, and this is the nitiest nit I've nitted at yet for this assignment, I would reverse the order of your if statements so it reads in the same order it prints. Here's how I would write the same code:

```python
# how I'd do this bit
for i in range(17):
bolt = c * (17 - i)
if i <= 5:
pad = ""
elif i <= 11:
pad = " "
else:
pad = " "
print pad + bolt
````

Obviously there is more than one way to go about each problem. Go with what makes the most sense to you.

## fraction.py
Well, the file works and the output is clean. The code is clean and unlike the last few, not really commented at all. One glaring thing is that python frowns upon the one line if statement. They are rarely used, but never if there is an else clause. They are just harder to read as a rule.

Anyways, an *interesting* solution. Well written though it took me a second to figure out what you were doing. Certainly more complicated than I was going for:

```python
# ..snip..
if numerator > denominator and denominator != 0:
wholeNum = numerator / denominator
remainder = numerator % denominator

if remainder == 0:
print "%d/%d = %d" % (numerator, denominator, wholeNum)
else:
print "%d/%d = %d %d/%d" % (numerator, denominator, wholeNum, remainder, denominator)
else:
print "No reduction needed: %d/%d = %d/%d" % (numerator, denominator, numerator, denominator)
```

## table.py
Another well done program with similar criticisms on spacing, comments, etc. Good use of functions, recursion, and lists. However, recursion is unecessary in this case. A different way to write this so it won't overflow the stack ever is:

```python
# remove the recursive table() call on line 24
# ..snip..

nums = []
while len(nums) < 5:
table()
```