elz: (ada-tubes)
elz ([personal profile] elz) wrote in [community profile] intro_to_cs2009-11-11 10:52 pm
Entry tags:

Poll & solutions

First:

Open to: Registered Users, detailed results viewable to: All, participants: 25


Tickyboxes!

View Answers

Finished lecture 2
24 (96.0%)

Finished problem set 1
15 (60.0%)



Also, it occurs to me that it might be handy to have a place to post/discuss solutions to the problem sets, to see what we can learn from each other in the absence of TAs. If you actually go to MIT and the problem sets are still the same, don't read these. ;)

Fire away!
zulu: Omar Epps, looking awesome (house - epps)

[personal profile] zulu 2009-11-16 04:26 am (UTC)(link)
On the other hand, check this out:

#odds

# This script will calculate the nth odd number

odd = 0
counter = 0
odds = []

print ("Let's find the nth odd number. Please enter a postive integer: ")
answer = raw_input()
nth = int(answer)

while counter < nth:
     if odd % 2 == 0:
          print str(odd) + (" is even. It doesn't go on the list.")
          odd = odd + 1
          print ("We have found ") + str(counter) +(" odd numbers. Let's keep going.")

     elif odd % 2 != 0:
          print str(odd) + " is odd. It goes on the list."
          odds.append(odd)
          if len(odds) == int(nth):
               print ("The ") + str(nth) + ("th odd number is ") + str(odd)
               break
          else:
               print ("We have found ") + str(len(odds)) +(" odd numbers. Let's keep going.")
               odd = odd + 1
               counter = counter + 1
Edited 2009-11-16 04:28 (UTC)