Preparing git repo for final project
This commit is contained in:
17
problems/pset1/interpreter/interpreter.py
Normal file
17
problems/pset1/interpreter/interpreter.py
Normal file
@@ -0,0 +1,17 @@
|
||||
def main():
|
||||
expression = input("Enter an arithmetic expression:\t\t")
|
||||
x, y, z = expression.split()
|
||||
result = 0.0
|
||||
if y == '+':
|
||||
result = int(x) + int(z)
|
||||
elif y == '-':
|
||||
result = int(x) - int(z)
|
||||
elif y == '*':
|
||||
result = int(x) * int(z)
|
||||
elif y == '/':
|
||||
result = int(x) / int(z)
|
||||
print(round(float(result), 1))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user