MCPcopy Create free account
hub / github.com/bslatkin/effectivepython / report_outcome

Method report_outcome

example_code/item_076.py:187–204  ·  view source on GitHub ↗
(self, number)

Source from the content-addressed store, hash-verified

185
186 print("Example 11")
187 def report_outcome(self, number):
188 new_distance = math.fabs(number - self.secret)
189
190 if new_distance == 0:
191 decision = CORRECT
192 elif self.last_distance is None:
193 decision = UNSURE
194 elif new_distance < self.last_distance:
195 decision = WARMER
196 elif new_distance > self.last_distance:
197 decision = COLDER
198 else:
199 decision = SAME
200
201 self.last_distance = new_distance
202
203 self.send(f"REPORT {decision}")
204 return decision
205
206
207 print("Example 12")

Callers 1

__iter__Method · 0.95

Calls 1

sendMethod · 0.45

Tested by

no test coverage detected