Skip to content

Commit 69d16d4

Browse files
committed
Update calculator.py
Undid the last commit. Oops again!
1 parent 39464df commit 69d16d4

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

calculator/api/calculator.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def set_equation(self, first_part: str | float| int, operator: Operator = None,
4343
"""Sets the current equation of the calculator.
4444
4545
>>> calc = Calculator()
46-
... calc.set_equation(2, Operator.MULTIPLY, 2)
47-
... calc.get_equation()
46+
>>> calc.set_equation(2, Operator.MULTIPLY, 2)
47+
>>> calc.get_equation()
4848
2 x 2
4949
"""
5050
self.equation_first = str(first_part)
@@ -60,8 +60,8 @@ def get_equation(self):
6060
"""Returns the current equation as a single line string.
6161
6262
>>> calc = Calculator()
63-
... calc.set_equation(2, Operator.MULTIPLY, 2)
64-
... calc.get_equation()
63+
>>> calc.set_equation(2, Operator.MULTIPLY, 2)
64+
>>> calc.get_equation()
6565
2 x 2
6666
"""
6767
eq = " ".join(self.equation_first, self.equation_type, self.equation_last)
@@ -73,9 +73,9 @@ def clear_entry(self):
7373
"""Removes the last entry from the calculator. This could be a digit or the current operator.
7474
7575
>>> calc = Calculator()
76-
... calc.set_equation(2, Operator.MULTIPLY, 2)
77-
... calc.clear_entry()
78-
... calc.clear_entry()
76+
>>> calc.set_equation(2, Operator.MULTIPLY, 2)
77+
>>> calc.clear_entry()
78+
>>> calc.clear_entry()
7979
2
8080
"""
8181
if self.current_part == "first":
@@ -97,9 +97,9 @@ def add_digit(self, digit: str | int):
9797
"""Adds a digit to the current number. Accepts str and int.
9898
9999
>>> calc = Calculator()
100-
... calc.add_digit('2')
101-
... calc.add_digit(4)
102-
... calc.get_equation()
100+
>>> calc.add_digit('2')
101+
>>> calc.add_digit(4)
102+
>>> calc.get_equation()
103103
24
104104
"""
105105
if self.current_part == "first":
@@ -112,11 +112,11 @@ def set_operator(self, operator: Operator):
112112
"""Sets the operator of the equation. Also changes the current number to the second one.
113113
114114
>>> calc = Calculator()
115-
... calc.add_digit(2)
116-
... calc.set_operator(Operator.ADD)
117-
... calc.add_digit(4)
118-
... calc.set_operator(Operator.SUB)
119-
... calc.get_equation()
115+
>>> calc.add_digit(2)
116+
>>> calc.set_operator(Operator.ADD)
117+
>>> calc.add_digit(4)
118+
>>> calc.set_operator(Operator.SUB)
119+
>>> calc.get_equation()
120120
2 - 4
121121
"""
122122
self.equation_type = operator
@@ -127,15 +127,15 @@ def flip_sign(self):
127127
"""Flips the sign of the current number.
128128
129129
>>> calc = Calculator()
130-
... calc.add_digit(2)
131-
... calc.flip_sign()
132-
... calc.get_equation()
130+
>>> calc.add_digit(2)
131+
>>> calc.flip_sign()
132+
>>> calc.get_equation()
133133
-2
134134
135135
>>> calc = Calculator()
136-
... calc.set_equation(-2)
137-
... calc.flip_sign()
138-
... calc.get_equation()
136+
>>> calc.set_equation(-2)
137+
>>> calc.flip_sign()
138+
>>> calc.get_equation()
139139
2
140140
"""
141141
if self.current_part == "first":
@@ -154,10 +154,10 @@ def add_decimal(self):
154154
"""Adds a decimal to the end of the current number if it doesn't have one. Otherwise it does nothing.
155155
156156
>>> calc = Calculator()
157-
... calc.add_digit(2)
158-
... calc.add_decimal()
159-
... calc.add_digit(5)
160-
... calc.get_equation()
157+
>>> calc.add_digit(2)
158+
>>> calc.add_decimal()
159+
>>> calc.add_digit(5)
160+
>>> calc.get_equation()
161161
2.5
162162
"""
163163
if self.current_part == "first":
@@ -172,9 +172,9 @@ def solve(self):
172172
"""Solves the equation currently stored in the calculator and sets the equation to the new result.
173173
174174
>>> calc = Calculator()
175-
... calc.set_equation(1, Operator.ADD, 1)
176-
... calc.solve()
177-
... calc.get_equation()
175+
>>> calc.set_equation(1, Operator.ADD, 1)
176+
>>> calc.solve()
177+
>>> calc.get_equation()
178178
2
179179
"""
180180
result = float(self.equation_first)

0 commit comments

Comments
 (0)