Skip to content

Conversation

@dianavermilya
Copy link
Collaborator

Grade 5/5

Hi Kevin, looks great. Remember to put your name on the file and take out the '#add your code here' here.

@ksuzy31
Copy link
Owner

ksuzy31 commented Mar 3, 2014

thanks diana

@abekim
Copy link
Collaborator

abekim commented Mar 4, 2014

One thing in your evaluate_random_function. I personally recommend using if...elif...else statements. From a reader's perspective, this tells them that you're matching for patterns with a single element.

This next part doesn't really apply to your code, but if you had written:

def evaluate_random_function(f, x, y):
    d = f[0]
    if d == 'x':
        res = x
    if d == 'y':
        res = y
    ...
    return res

then Python will evaluate each one of your if statements even if it finds a match (ie. f = ['x']). If you use if...elif, Python will know to stop once it's found a match. Let me know if this makes sense!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants