MCPcopy Index your code
hub / github.com/ndleah/python-mini-project / calculate

Function calculate

Smart_Calculator/calculator.py:43–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

41 return l
42
43def calculate():
44 text = textin.get()
45 for word in text.split(' '):
46 if word.upper() in operations.keys():
47 try:
48 l = extract_from_text(text)
49 r = operations[word.upper()](l[0], l[1])
50 list.delete(0,END)
51 list.insert(END,r)
52 except:
53 list.delete(0,END)
54 list.insert(END,'something went wrong please enter again')
55 finally:
56 break
57 elif word.upper() not in operations.keys():
58 list.delete(0,END)
59 list.insert(END,'something went wrong please enter again')
60
61operations = {'ADD':add,'ADDITION':add, 'SUM':add, 'PLUS':add,
62 'SUB':sub, 'DIFFERENCE':sub, 'MINUS': sub, 'SUBTRACT':sub, 'DIFF':sub,

Callers

nothing calls this directly

Calls 3

extract_from_textFunction · 0.85
splitMethod · 0.80
insertMethod · 0.80

Tested by

no test coverage detected