Updated the Variable object to reconize 'k' as an installment variable type. Updated the main program's interactive UI.
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
__pycache__
|
__pycache__
|
||||||
*.json
|
*.json
|
||||||
|
*.txt
|
||||||
|
|||||||
+3
-1
@@ -19,7 +19,9 @@ class Variable:
|
|||||||
"i" : "Interest",
|
"i" : "Interest",
|
||||||
"I" : "Interest",
|
"I" : "Interest",
|
||||||
"n" : "Time",
|
"n" : "Time",
|
||||||
"N" : "Time"
|
"N" : "Time",
|
||||||
|
"k" : "Installment",
|
||||||
|
"K" : "Installment"
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, name, type, starting_point = 0, ending_point = 0):
|
def __init__(self, name, type, starting_point = 0, ending_point = 0):
|
||||||
|
|||||||
@@ -8,9 +8,10 @@ import itertools
|
|||||||
import copy
|
import copy
|
||||||
|
|
||||||
base_list = [1, 2, 4, 6, 12]
|
base_list = [1, 2, 4, 6, 12]
|
||||||
tolerance = .28
|
tolerance = .05
|
||||||
|
|
||||||
variables = {}
|
variables = {}
|
||||||
|
|
||||||
def print_vars(vars):
|
def print_vars(vars):
|
||||||
i = 0
|
i = 0
|
||||||
for key in vars.keys():
|
for key in vars.keys():
|
||||||
@@ -74,10 +75,21 @@ def modify_variable(var, vars):
|
|||||||
|
|
||||||
exp_str = input("Enter the expression the student will use: ")
|
exp_str = input("Enter the expression the student will use: ")
|
||||||
wrong_response = input("Enter the wrong response for the expression: ")
|
wrong_response = input("Enter the wrong response for the expression: ")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
wrong_response = float(wrong_response)
|
wrong_response = float(wrong_response)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print("The anwser must be numeric! Will not be included in output file.")
|
print("The wrong response must be numeric.")
|
||||||
|
exit()
|
||||||
|
|
||||||
|
tolerance = input("Enter the tolerance to use: ")
|
||||||
|
|
||||||
|
try:
|
||||||
|
tolerance = float(tolerance)
|
||||||
|
except ValueError:
|
||||||
|
print("The tolerance must be numeric.")
|
||||||
|
exit()
|
||||||
|
|
||||||
tokens = tokenizer.get_tokens_from_expression_string(exp_str)
|
tokens = tokenizer.get_tokens_from_expression_string(exp_str)
|
||||||
rev_tokens = copy.deepcopy(tokens)
|
rev_tokens = copy.deepcopy(tokens)
|
||||||
#rev_tokens.reverse()
|
#rev_tokens.reverse()
|
||||||
@@ -88,6 +100,8 @@ for t in rev_tokens:
|
|||||||
|
|
||||||
selected_variable = None
|
selected_variable = None
|
||||||
|
|
||||||
|
if len(variables) > 0:
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
print("Variables in expression:")
|
print("Variables in expression:")
|
||||||
print_vars(variables)
|
print_vars(variables)
|
||||||
|
|||||||
Reference in New Issue
Block a user