You are on page 1of 2

1. Are the following expressions correct (yes or no)?

If not correct, why not? Assume all variables have


already been assigned values.

Expression Syntax If not correct,


Correct re-write it?
?

exp = 25 Yes

exp = 2( a - b ) No exp = 2 * ( a - b )

exp = A - b/c + D Yes

exp = ( (x+y) / z ) / ( Yes


a - b )

exp = 25 - value Yes

exp = (a-b) * (c-d) Yes

exp = -sum + partial Yes

exp = ((m - n) + No exp = ((m - n) +


(w-x-z) / (p % q ) (w-x-z) / (p % q ))

2. What will be the result of each expression listed


below?

Expression
Result Expression Result

7%3 1 7%5 2
10%5 0 10%6 4
129%10 9 1999%100 99
17%2 1 18%2 0

3. Given 2 sides of a right triangle, find 3 different


methods to write a single expression to find the
hypotenuse c.

Python arithmetic operators:


https://www.w3schools.com/python/python_operators.asp

Python math module:


https://www.w3schools.com/python/module_math.asp

Method Expression

Using the arithmetic


operators only to C = (a**2 + b**2) ** 1/2
find the square and
the square root of a
number.

Using 2 different C = math.sqrt(math.pow(a, 2) + math.pow(b, 2))


math module methods:
one to find the
square and one to
find the square root
of a number.

Using a single math c = math.hypot(a, b)


module method to find
c.

You might also like