Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Technical Interview Prep: Python Basics Basic Python How Do You Like Them Apples

Noor Hafiza Binti Ibrahim
Noor Hafiza Binti Ibrahim
11,712 Points

Bummer: Uh oh, I didn't get the correct value returned. It should have been 50. Instead, it was 150

Your function will need to complete the math operation and return the result. example: mathy('divide', 15, 5) return 3

mathy.py
# enter your code below
def mathy(a, b, c):
    add = b + c
    return add

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

Hey Noor Hafiza Binti Ibrahim, the first parameter receives a string argument that is the name of a math operator. The function returns the result of this operator used between b and c.

An if/elif/else statement works well here to match the operator string. The body of each code block could simply be returning the result of the math operation being applied. For example

if a == β€œdivide”:
    return b / c
elif ....
```Python 

Post back if you need more help. Good luck!!!