[Tutor] if statement help

Danny Yoo dyoo at hashcollision.org
Mon Mar 30 03:39:25 CEST 2015


On Thu, Mar 26, 2015 at 5:42 PM, Priya Persaud <pp8407 at gmail.com> wrote:
> Hello,
>
> I recently learned about if statements and math functions. For my class we
> are unit testing absolute values and have to make if statements so the
> tests pass, but we cannot use built in functions like (abs). How do I start
> it, I am so lost.
>
> Thank you


There are multiple situations where we need to teach the computer to
compute a function, where it doesn't know about the function already.
Your teacher appears to be trying to teach you how to build basic
functions, which is admirable.


Pretend that you're talking to someone who doesn't know what the
absolute value function does.

  * Can you say what the absolute value function does?  What's its purpose?

  * Can you give a few examples of inputs and expected outputs of the function?


By the way, if you have some free time, you might find the following
book helpful: http://www.ccs.neu.edu/home/matthias/HtDP2e/  It's not
Python, but it tries to teach how to tackle the kind of programming
problems you'll see in a beginner's class.  What's good about it is
that it concentrates on methodology and problem-solving strategies,
all to keep yourself from getting lost.


More information about the Tutor mailing list