Fractions, percentages and order of operations
Fractions and percentages (lesson 0.3.1)
0 of 6 correct
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
How to type answers
- Powers with
^:x^7,2^(1/3),a^-2. - Multiply with
*or by writing side by side:3x^2,2(x+1). ln(x)is the natural log,log(x, 2)is log base 2,eis Euler's number,sqrt(x)is a square root.sin(x),cos(x)andtan(x)take radians; writepifor π andsin(x)^2for sin²x.- Your first answer to each question is saved: it counts towards your score and brings the question back for review.
- Exact answers like
ln(20)/ln(3)are best. Decimals need about 4 significant figures.
Rearranging equations
Solving and rearranging (lesson 0.3.2)
0 of 5 correct
- 1.
- 2.
- 3.
- 4.
- 5.
How to type answers
- Powers with
^:x^7,2^(1/3),a^-2. - Multiply with
*or by writing side by side:3x^2,2(x+1). ln(x)is the natural log,log(x, 2)is log base 2,eis Euler's number,sqrt(x)is a square root.sin(x),cos(x)andtan(x)take radians; writepifor π andsin(x)^2for sin²x.- Your first answer to each question is saved: it counts towards your score and brings the question back for review.
- Exact answers like
ln(20)/ln(3)are best. Decimals need about 4 significant figures.
Inequalities and absolute value
Inequalities and absolute value (lesson 0.3.3)
0 of 5 correct
- 1.
- 2.
- 3.
- 4.
- 5.
How to type answers
- Powers with
^:x^7,2^(1/3),a^-2. - Multiply with
*or by writing side by side:3x^2,2(x+1). ln(x)is the natural log,log(x, 2)is log base 2,eis Euler's number,sqrt(x)is a square root.sin(x),cos(x)andtan(x)take radians; writepifor π andsin(x)^2for sin²x.- Your first answer to each question is saved: it counts towards your score and brings the question back for review.
- Exact answers like
ln(20)/ln(3)are best. Decimals need about 4 significant figures.
Coding exercise
Solve any linear equation
Write solve_linear(a, b, c, d) that returns the solving .
- Gather and factor as in lesson 0.3.2: .
- When
a == cthere is no single answer. RaiseValueError.
The tests include answers that are fractions and negative numbers, and they check each answer by putting it back into the equation.
See the tests
def _raises_value_error(*args):
try:
solve_linear(*args)
except ValueError:
return True
return False
def test_x_on_one_side():
"""3x + 5 = 20 gives x = 5"""
expect_close(solve_linear(3, 5, 0, 20), 5.0, what="solve_linear(3, 5, 0, 20)")
def test_x_on_both_sides():
"""5x − 3 = 2x + 9 gives x = 4"""
expect_close(solve_linear(5, -3, 2, 9), 4.0, what="solve_linear(5, -3, 2, 9)")
def test_negative_answer():
"""6x + 4 = 2x − 8 gives x = −3"""
expect_close(solve_linear(6, 4, 2, -8), -3.0, what="solve_linear(6, 4, 2, -8)")
def test_fraction_answer():
"""2x + 1 = 5x gives x = 1/3"""
expect_close(solve_linear(2, 1, 5, 0), 1 / 3, what="solve_linear(2, 1, 5, 0)")
def test_answer_checks_out():
"""Putting the answer back in makes both sides equal: 0.7x + 2.5 = −1.3x + 9"""
x = solve_linear(0.7, 2.5, -1.3, 9)
expect_close(0.7 * x + 2.5, -1.3 * x + 9, what="left side vs right side at your x")
def test_no_single_answer():
"""2x + 1 = 2x + 5 has no single answer, so raise ValueError"""
assert _raises_value_error(2, 1, 2, 5), "expected ValueError when a == c"