Computer Science 15-112, Fall 2011
Class Notes: Practice (through week 3)
- Programming practice...
Note #1: some of these sources are not in Python, or are not
even presented as programming problems at all. You may need to use
an ounce of cleverness to convert the given items to programming
problems. For example, consider the statement: "6 is the
smallest perfect number." First, you could simply write a program
to verify this fact (of course, you'll need to look up what a perfect
number is, but alas, that's part of the problem-solving process).
Even better, you could translate it into a more interesting problem,
such as this: write the function nthPerfectNumber that takes a
non-negative integer n and returns the nth perfect number. Et
voila!
Note #2: not every item here is amenable to practice this week.
Some problems at the given sites require techniques beyond what we have
covered so far in this course. This should usually be clear, but
if you are unsure if a given problem is solvable using just what we have
so far covered, ask your CA.
- Tracing and Mystery Methods
Note: Best bet is to go to my CMU home page, go to previous
semesters, and just poke around until you find lots of these problems.
Also, you can always make your own problems, especially trace problems
(mystery functions are a bit more complicated to make). Just take
anything from the notes, tweak the constants a little, and see if you
can predict the new output. In any case, here are some relevant
portions of recent semester's recitations, quizzes, and tests:
- F10:
rec3,
rec4,
quiz2,
quiz3,
quiz4,
midterm1,
hw3,
hw4
- S11:
quiz2,
quiz3,
this lecture, and
this lecture,
midterm1-practice,
midterm1
carpe diem -
carpe diem - carpe diem - carpe diem
- carpe diem - carpe diem -
carpe diem - carpe diem - carpe
diem