

import unittest

from transformers.testing_utils import CaptureStdout
from transformers.tools.python_interpreter import evaluate




def 			UpperCAmelCase__				(			_A      : List[str]							):





  '''simple docstring'''







  return x + 2







class 						__magic_name__			(							unittest.TestCase							):

   '''simple docstring'''




   def  _UpperCAmelCase (				self       )							->    Optional[int]:






     """simple docstring"""






     a__  ='''x = 3'''
     a__  ={}
     a__  =evaluate(lowercase_,    {},    state=lowercase_       )
     assert result == 3
     self.assertDictEqual(lowercase_,    {'''x''': 3}       )

     a__  ='''x = y'''
     a__  ={'''y''': 5}
     a__  =evaluate(lowercase_,    {},    state=lowercase_       )
     # evaluate returns the value of the last assignment.
     assert result == 5
     self.assertDictEqual(lowercase_,    {'''x''': 5, '''y''': 5}       )



   def  _UpperCAmelCase (				self       )							->    Any:






     """simple docstring"""






     a__  ='''y = add_two(x)'''
     a__  ={'''x''': 3}
     a__  =evaluate(lowercase_,    {'''add_two''': add_two},    state=lowercase_       )
     assert result == 5
     self.assertDictEqual(lowercase_,    {'''x''': 3, '''y''': 5}       )

     # Won't work without the tool
     with CaptureStdout() as out:
       a__  =evaluate(lowercase_,    {},    state=lowercase_       )
     assert result is None
     assert "tried to execute add_two" in out.out



   def  _UpperCAmelCase (				self       )							->    List[Any]:






     """simple docstring"""






     a__  ='''x = 3'''
     a__  ={}
     a__  =evaluate(lowercase_,    {},    state=lowercase_       )
     assert result == 3
     self.assertDictEqual(lowercase_,    {'''x''': 3}       )



   def  _UpperCAmelCase (				self       )							->    int:






     """simple docstring"""






     a__  ='''test_dict = {\'x\': x, \'y\': add_two(x)}'''
     a__  ={'''x''': 3}
     a__  =evaluate(lowercase_,    {'''add_two''': add_two},    state=lowercase_       )
     self.assertDictEqual(lowercase_,    {'''x''': 3, '''y''': 5}       )
     self.assertDictEqual(lowercase_,    {'''x''': 3, '''test_dict''': {'''x''': 3, '''y''': 5}}       )



   def  _UpperCAmelCase (				self       )							->    List[str]:






     """simple docstring"""






     a__  ='''x = 3\ny = 5'''
     a__  ={}
     a__  =evaluate(lowercase_,    {},    state=lowercase_       )
     # evaluate returns the value of the last assignment.
     assert result == 5
     self.assertDictEqual(lowercase_,    {'''x''': 3, '''y''': 5}       )



   def  _UpperCAmelCase (				self       )							->    int:






     """simple docstring"""






     a__  ='''text = f\'This is x: {x}.\''''
     a__  ={'''x''': 3}
     a__  =evaluate(lowercase_,    {},    state=lowercase_       )
     # evaluate returns the value of the last assignment.
     assert result == "This is x: 3."
     self.assertDictEqual(lowercase_,    {'''x''': 3, '''text''': '''This is x: 3.'''}       )



   def  _UpperCAmelCase (				self       )							->    Any:






     """simple docstring"""






     a__  ='''if x <= 3:\n    y = 2\nelse:\n    y = 5'''
     a__  ={'''x''': 3}
     a__  =evaluate(lowercase_,    {},    state=lowercase_       )
     # evaluate returns the value of the last assignment.
     assert result == 2
     self.assertDictEqual(lowercase_,    {'''x''': 3, '''y''': 2}       )

     a__  ={'''x''': 8}
     a__  =evaluate(lowercase_,    {},    state=lowercase_       )
     # evaluate returns the value of the last assignment.
     assert result == 5
     self.assertDictEqual(lowercase_,    {'''x''': 8, '''y''': 5}       )



   def  _UpperCAmelCase (				self       )							->    Tuple:






     """simple docstring"""






     a__  ='''test_list = [x, add_two(x)]'''
     a__  ={'''x''': 3}
     a__  =evaluate(lowercase_,    {'''add_two''': add_two},    state=lowercase_       )
     self.assertListEqual(lowercase_,    [3, 5]       )
     self.assertDictEqual(lowercase_,    {'''x''': 3, '''test_list''': [3, 5]}       )



   def  _UpperCAmelCase (				self       )							->    int:






     """simple docstring"""






     a__  ='''y = x'''
     a__  ={'''x''': 3}
     a__  =evaluate(lowercase_,    {},    state=lowercase_       )
     assert result == 3
     self.assertDictEqual(lowercase_,    {'''x''': 3, '''y''': 3}       )



   def  _UpperCAmelCase (				self       )							->    str:






     """simple docstring"""






     a__  ='''test_list = [x, add_two(x)]\ntest_list[1]'''
     a__  ={'''x''': 3}
     a__  =evaluate(lowercase_,    {'''add_two''': add_two},    state=lowercase_       )
     assert result == 5
     self.assertDictEqual(lowercase_,    {'''x''': 3, '''test_list''': [3, 5]}       )

     a__  ='''test_dict = {\'x\': x, \'y\': add_two(x)}\ntest_dict[\'y\']'''
     a__  ={'''x''': 3}
     a__  =evaluate(lowercase_,    {'''add_two''': add_two},    state=lowercase_       )
     assert result == 5
     self.assertDictEqual(lowercase_,    {'''x''': 3, '''test_dict''': {'''x''': 3, '''y''': 5}}       )



   def  _UpperCAmelCase (				self       )							->    int:






     """simple docstring"""






     a__  ='''x = 0\nfor i in range(3):\n    x = i'''
     a__  ={}
     a__  =evaluate(lowercase_,    {'''range''': range},    state=lowercase_       )
     assert result == 2
     self.assertDictEqual(lowercase_,    {'''x''': 2, '''i''': 2}       )



def 			UpperCAmelCase__				(			):





  '''simple docstring'''







  return [
      a * b * (10_00 - a - b)
      for a in range(1	,      9_99							)
      for b in range(_A	,      9_99							)
      if (a * a + b * b == (10_00 - a - b) ** 2)
  ][0]


if __name__ == "__main__":
       print(f"""{solution() = }""")
