```python
from IPython.display import HTML

hide_me = ''
HTML('''
<form action="javascript:code_toggle()"><input style="opacity:0" type="submit" value="Click here to toggle on/off the raw code."></form>''')
```

## Exercise

Solve this system of equations for $x$ and $y$.

$$
\begin{equation}
  \begin{cases}
    y = x + 3 \\ 
    y - 12 = -2x 
  \end{cases}
\end{equation}
$$

Write a function `ex()` to return SymPy equations for `x` and `y`.


```python
from sympy import symbols, Eq, simplify


def ex():
    x, y = symbols('x y')
    my_x, my_y = Eq(x, 0), Eq(y, 0)

    print('Starting equations:')
    eq1, eq2 = Eq(y, x + 3), Eq(y - 12, -2*x)
    display(eq1)
    display(eq2)
    
    print('Your solution:')
    # YOUR CODE HERE
    raise NotImplementedError()
        
    return(my_x, my_y)


x_ans, y_ans = ex()  # Test out results
print('Your answer:')
display(x_ans)
display(y_ans)
```


```python
# hide_me

import unittest
import inspect

x, y = symbols('x y')

enable_print  = print
enable_display = display
disable_print = lambda *x, **y: None
disable_display = lambda *x, **y: None

print = disable_print
display = disable_display
    
class TestSystemEquations(unittest.TestCase):

    def test_functionExists(self):
        """You should have a function ex() defined."""
        self.assertTrue('ex' in globals())

    def test_xAnswer(self):
        """Your x answer should equal 3."""
        self.assertEqual(simplify(ex()[0]), Eq(x, 3))
        
    def test_xSet(self):
        """You should not directly assign the x answer."""
        self.assertTrue('Eq(x, 3)' not in inspect.getsource(ex))

    def test_yAnswer(self):
        """Your y answer should be 6."""
        self.assertEqual(simplify(ex()[1]), Eq(y, 6))

    def test_ySet(self):
        """You should not directly assign the y answer."""
        self.assertTrue('Eq(y, 6)' not in inspect.getsource(ex))

    def test_useLHS(self):
        """You should use the .lhs attribute."""
        self.assertTrue('.lhs' in inspect.getsource(ex))
        
    def test_useRHS(self):
        """You should use the .rhs attribute."""
        self.assertTrue('.lhs' in inspect.getsource(ex))

    def test_noSolver(self):
        """You should not use the solve function."""
        self.assertTrue('solve' not in inspect.getsource(ex))
    
    def test_noLinearSolver(self):
        """You should not use the solve_linear_systems function."""
        self.assertTrue('solve_linear_system' not in inspect.getsource(ex))
    
    def test_returnEquations(self):
        """Your function should return SymPy equations."""
        self.assertTrue(type(ex()[1]) == Eq and type(ex()[1]) == Eq)


def suite():
    suite = unittest.TestSuite()
    suite.addTest(TestSystemEquations('test_functionExists'))
    suite.addTest(TestSystemEquations('test_xAnswer'))
    suite.addTest(TestSystemEquations('test_xSet'))
    suite.addTest(TestSystemEquations('test_yAnswer'))
    suite.addTest(TestSystemEquations('test_ySet'))
    suite.addTest(TestSystemEquations('test_useLHS'))
    suite.addTest(TestSystemEquations('test_useRHS'))
    suite.addTest(TestSystemEquations('test_noSolver'))
    suite.addTest(TestSystemEquations('test_noLinearSolver'))
    suite.addTest(TestSystemEquations('test_returnEquations'))
    return suite


runner = unittest.TextTestRunner(verbosity=2)
runner.run(suite())

# Reset suppression of print statements
print = enable_print
display = enable_display
```


```python

```

b9b1f2e0a3a352cd159d239de1cc8d90f1ba14a9
ipynb
Jupyter Notebook
release/solve_line_intersection/sys_of_eq.ipynb
erictleung/machine-learning
9467e9dc951697a962062b2c1c1caa225cc65bb8
MIT
2021-02-04T20:16:35.000Z
2021-06-15T20:02:23.000Z
release/solve_line_intersection/sys_of_eq.ipynb
erictleung/data-science
9467e9dc951697a962062b2c1c1caa225cc65bb8
MIT
2017-06-10T18:14:31.000Z
2017-11-01T02:32:51.000Z
release/solve_line_intersection/sys_of_eq.ipynb
erictleung/machine-learning
9467e9dc951697a962062b2c1c1caa225cc65bb8
MIT
2021-02-04T20:16:37.000Z
2021-03-13T15:03:09.000Z
Qwen/Qwen-72B
1. YES
2. YES

