---
metadata:
    display_name: Custom Python-Evaluated Input
    markdown: !!null
data: |
      <problem>
      <p>
      A custom python-evaluated input problem accepts one or more lines of text input from the
      student, and evaluates the inputs for correctness based on evaluation using a 
      python script embedded within the problem.
      </p>

      <script type="loncapa/python">

      def test_add(expect, ans):
          try:
              a1=int(ans[0])
              a2=int(ans[1])
              return (a1+a2) == int(expect)
          except ValueError:
              return False

      def test_add_to_ten(expect, ans):
          return test_add(10, ans)

      </script>

      <p>Enter two integers which sum to 10: </p>
      <customresponse cfn="test_add_to_ten">
              <textline size="40" correct_answer="3" label="Integer #1"/><br/>
              <textline size="40" correct_answer="7" label="Integer #2"/>
      </customresponse>

      <p>Enter two integers which sum to 20: </p>
      <customresponse cfn="test_add" expect="20">
              <textline size="40" correct_answer="11" label="Integer #1"/><br/>
              <textline size="40" correct_answer="9" label="Integer #2"/>
      </customresponse>
    
          <solution>
              <div class="detailed-solution">
                  <p>Explanation</p>
                  <p>Any set of integers on the line \(y = 10 - x\) and \(y = 20 - x\) satisfy these constraints.</p>
                  <p>You can also add images within the solution clause like so:</p>
                  <img src="/static/images/placeholder-image.png"/>
              </div>
          </solution>
      </problem>
