blob: fb116d96a11067a8d7542b6341ad9d17823aaf9e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/usr/bin/python3
'''
Week 143:
https://theweeklychallenge.org/blog/perl-weekly-challenge-143
Task #1: Calculator
You are given a string, `$s`, containing mathematical expression.
Write a script to print the result of the mathematical expression. To keep it simple, please only accept `+ - * ()`.
'''
import unittest
#
#
# Unit test class
class TestJortSort(unittest.TestCase):
def test_example_1(self):
self.assertEqual(eval('10 + 20 - 5'), 25, 'Example 1')
def test_example_2(self):
self.assertEqual(eval('(10 + 20 - 5) * 2'), 50, 'Example 2')
unittest.main()
|