2017-09-15

posted Sep 15, 2017, 6:18 AM by Samuel Konstantinovich

Do Now:

Log in, then lock your screen. (winkey-L or top right menu with switch user)


In your notebook:

    Write a function (SumOfSquares a b) that takes numeric inputs a, b and returns the sum of their squares.

e.g.,

    (SumOfSquares 0 0) → 0

    (SumOfSquares 1 2) → 5

    (SumOfSquares 4 5) → 41


Goal: Explore more functions, get comfortable poking around

Go Over Get Ones/Tens/Nth Digit

Classwork:

1.Test your sumOfSquares solution.

2. You are now tasked with figuring out some more information about how some built in functions work.

For each function or functions a-e you must figure out via experimentation and testing (not looking it up)

    i. How many parameters can it take? (don’t just guess, test a few things)

    ii What is the rule for the how the function works? (Cover all cases including when they behave differently when you change the number of parameters. Write answers in English, not code.)

a. Absolute value

b. maximum

c. rounding

d. +,-

e. *,/


As you test, write down your findings for each function on paper, so as to convince me you tested and know what is going on.



Challenge problem (Think about this for later)

How might you be able to calculate the maximum of two numerical values using only:

+

-

*

/

abs


If you use the method on 5 and 12 the result of the expression should be 12.

If you use the method on 12 and 5 the result of the expression should be 12.

If you use the method on 5 and -12 the result of the expression should be 5.

If you use the method on -2 and 2 the result of the expression should be 2.

Hint:  Draw a number line and sketch out what happens when you perform operations, this is more helpful than typing random things.
Comments