当前位置: 首页>>代码示例>>Python>>正文


Python wordy.calculate函数代码示例

本文整理汇总了Python中wordy.calculate函数的典型用法代码示例。如果您正苦于以下问题:Python calculate函数的具体用法?Python calculate怎么用?Python calculate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了calculate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_subtract_twice

 def test_subtract_twice(self):
     self.assertEqual(-7, calculate("What is 20 minus 14 minus 13?"))
开发者ID:MaxyMoos,项目名称:exercism_python,代码行数:2,代码来源:wordy_test.py

示例2: test_multiply_twice

 def test_multiply_twice(self):
     self.assertEqual(-12, calculate("What is 2 multiplied by -2 multiplied by 3?"))
开发者ID:MaxyMoos,项目名称:exercism_python,代码行数:2,代码来源:wordy_test.py

示例3: test_add_twice

 def test_add_twice(self):
     self.assertEqual(4, calculate("What is 1 plus 2 plus 1?"))
开发者ID:MaxyMoos,项目名称:exercism_python,代码行数:2,代码来源:wordy_test.py

示例4: test_add_then_subtract

 def test_add_then_subtract(self):
     self.assertEqual(14, calculate("What is 1 plus 5 minus -8?"))
开发者ID:MaxyMoos,项目名称:exercism_python,代码行数:2,代码来源:wordy_test.py

示例5: test_invalid_operation

 def test_invalid_operation(self):
     with self.assertRaises(ValueError) as context:
         calculate("What is 4 xor 7?")
     self.assertEqual(context.exception.message, 'Ill-formed question')
开发者ID:betegelse,项目名称:xpython,代码行数:4,代码来源:wordy_test.py

示例6: test_add_more_digits

 def test_add_more_digits(self):
     self.assertEqual(45801, calculate("What is 123 plus 45678?"))
开发者ID:MaxyMoos,项目名称:exercism_python,代码行数:2,代码来源:wordy_test.py

示例7: test_simple_mult

 def test_simple_mult(self):
     self.assertEqual(21, calculate("What is 7 multiplied by 3?"))
开发者ID:MaxyMoos,项目名称:exercism_python,代码行数:2,代码来源:wordy_test.py

示例8: test_simple_add_1

 def test_simple_add_1(self):
     self.assertEqual(18, calculate("What is 5 plus 13?"))
开发者ID:MaxyMoos,项目名称:exercism_python,代码行数:2,代码来源:wordy_test.py

示例9: test_simple_sub_1

 def test_simple_sub_1(self):
     self.assertEqual(6, calculate("What is 103 minus 97?"))
开发者ID:MaxyMoos,项目名称:exercism_python,代码行数:2,代码来源:wordy_test.py

示例10: test_simple_sub_2

 def test_simple_sub_2(self):
     self.assertEqual(-6, calculate("What is 97 minus 103?"))
开发者ID:MaxyMoos,项目名称:exercism_python,代码行数:2,代码来源:wordy_test.py

示例11: test_irrelevant_question

 def test_irrelevant_question(self):
     with self.assertRaises(ValueError) as context:
         calculate("Which is greater, 3 or 2?")
     self.assertEqual(context.exception.message, 'Ill-formed question')
开发者ID:betegelse,项目名称:xpython,代码行数:4,代码来源:wordy_test.py

示例12: test_missing_number

 def test_missing_number(self):
     with self.assertRaises(ValueError) as context:
         calculate("What is 7 plus times -2?")
     self.assertEqual(context.exception.message, 'Ill-formed question')
开发者ID:betegelse,项目名称:xpython,代码行数:4,代码来源:wordy_test.py

示例13: test_missing_operation

 def test_missing_operation(self):
     with self.assertRaises(ValueError) as context:
         calculate("What is 2 2 minus 3?")
     self.assertEqual(context.exception.message, 'Ill-formed question')
开发者ID:betegelse,项目名称:xpython,代码行数:4,代码来源:wordy_test.py

示例14: test_add_then_multiply

 def test_add_then_multiply(self):
     self.assertEqual(-8, calculate("What is -3 plus 7 multiplied by -2?"))
开发者ID:MaxyMoos,项目名称:exercism_python,代码行数:2,代码来源:wordy_test.py

示例15: test_simple_div

 def test_simple_div(self):
     self.assertEqual(9, calculate("What is 45 divided by 5?"))
开发者ID:MaxyMoos,项目名称:exercism_python,代码行数:2,代码来源:wordy_test.py


注:本文中的wordy.calculate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。