diff options
author | Matthew Strapp <msattr@gmail.com> | 2019-09-11 14:38:13 -0500 |
---|---|---|
committer | Matthew Strapp <msattr@gmail.com> | 2019-09-11 14:38:13 -0500 |
commit | b0e26a1a320fba0a8d21b5becd5c18023c1a3d94 (patch) | |
tree | 525d4b957019c201101301e26b9cb91b05f82be7 /csci1913/lab1 | |
parent | LAB (diff) | |
download | homework-b0e26a1a320fba0a8d21b5becd5c18023c1a3d94.tar homework-b0e26a1a320fba0a8d21b5becd5c18023c1a3d94.tar.gz homework-b0e26a1a320fba0a8d21b5becd5c18023c1a3d94.tar.bz2 homework-b0e26a1a320fba0a8d21b5becd5c18023c1a3d94.tar.lz homework-b0e26a1a320fba0a8d21b5becd5c18023c1a3d94.tar.xz homework-b0e26a1a320fba0a8d21b5becd5c18023c1a3d94.tar.zst homework-b0e26a1a320fba0a8d21b5becd5c18023c1a3d94.zip |
Start lab
Diffstat (limited to '')
-rw-r--r-- | csci1913/lab1/lab1_strap012.py | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/csci1913/lab1/lab1_strap012.py b/csci1913/lab1/lab1_strap012.py new file mode 100644 index 0000000..43fd8ae --- /dev/null +++ b/csci1913/lab1/lab1_strap012.py @@ -0,0 +1,66 @@ +def left(exp): + return exp[0] +def op(exp): + return exp[1] +def right(exp): + return exp[2] +def isInside(var, e): + if left(e)==var or right(e)==var: + return True + else: + return False + + + + + +# +# TESTS. Test the equation solver for CSci 1913 Lab 1. +# +# James Moen +# 10 Sep 18 +# +# Every test is followed by a comment which shows what must be printed if your +# code works correctly. It also shows how many points the test is worth, for a +# total of 35 possible points. +# + +print(isInside('x', 'x')) # True 1 point +print(isInside('x', 'y')) # False 1 point +print(isInside('x', ('x', '+', 'y'))) # True 2 points +print(isInside('x', ('a', '+', 'b'))) # False 2 points +print(isInside('+', ('a', '+', 'b'))) # False 2 points +print(isInside('x', (('m', '*', 'x'), '+', 'b'))) # True 2 points + +print(solve('x', (('a', '+', 'x'), '=', 'c'))) +# ('x', '=', ('c', '-', 'a')) 2 points + +print(solve('x', (('x', '+', 'b'), '=', 'c'))) +# ('x', '=', ('c', '-', 'b')) 2 points + +print(solve('x', (('a', '-', 'x'), '=', 'c'))) +# ('x', '=', ('a', '-', 'c')) 2 points + +print(solve('x', (('x', '-', 'b'), '=', 'c'))) +# ('x', '=', ('c', '+', 'b')) 2 points + +print(solve('x', (('a', '*', 'x'), '=', 'c'))) +# ('x', '=', ('c', '/', 'a')) 2 points + +print(solve('x', (('x', '*', 'b'), '=', 'c'))) +# ('x', '=', ('c', '/', 'b')) 2 points + +print(solve('x', (('a', '/', 'x'), '=', 'c'))) +# ('x', '=', ('a', '/', 'c')) 2 points + +print(solve('x', (('x', '/', 'b'), '=', 'c'))) +# ('x', '=', ('c', '*', 'b')) 2 points + +print(solve('y', ('y', '=', (('m', '*', 'x'), '+', 'b')))) +# ('y', '=', (('m', '*', 'x'), '+', 'b')) 2 points + +print(solve('x', ('y', '=', (('m', '*', 'x'), '+', 'b')))) +# ('x', '=', (('y', '-', 'b'), '/', 'm')) 2 points + +print(solve('a', (('b', '+', 'c'), '=', ('d', '*', (('a', '/', 'e'), '-', 'f'))))) +# ('a', '=', (((('b', '+', 'c'), '/', 'd'), '+', 'f'), '*', 'e')) 5 points
\ No newline at end of file |