Re: Project 4 Help

10 views
Skip to first unread message

Søren Kyale

unread,
May 4, 2013, 4:16:58 PM5/4/13
to uic-mcs...@googlegroups.com
If a is your polynomail. Then to use it's polyPrime method you would reference a, as in:
a.polyPrime()

because a already contains its list and degree you don't need to pass that information. That is what the self is for in the defined method.

The contract for your poly prime method should be.
# self.polyPrime: none -> None

So if a is of the Poly class
a.polyPrime()
will transform a into the derivative of a and return None.
so 
a = a.polyPrime()
will overwrite (technically, swap tags leaving the Poly formally known as a in limbo unless it's also known by another tag) a with None. 

The 
# myfunction: input -> output
style that Jeremy introduced is very helpful for solving this type of problem because it forces you to think about what goes in and what comes out. That is the contract. If the contracts are good then you'll get something.

Lowman will be happy if you use """myfunction: input -> output""" instead of the pound notation.

The doc string goes on the first indent after the function.
Example:
def myfunction():
     """myfunction: none -> None
         this function contains this here docstring.
         it takes no input and returns None as output"""
Reply all
Reply to author
Forward
0 new messages