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

Method report_outcome

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

Source from the content-addressed store, hash-verified

401
402 print("Example 25")
403 async def report_outcome(self, number): # Changed
404 new_distance = math.fabs(number - self.secret)
405
406 if new_distance == 0:
407 decision = CORRECT
408 elif self.last_distance is None:
409 decision = UNSURE
410 elif new_distance < self.last_distance:
411 decision = WARMER
412 elif new_distance > self.last_distance:
413 decision = COLDER
414 else:
415 decision = SAME
416
417 self.last_distance = new_distance
418
419 await self.send(f"REPORT {decision}") # Changed
420 return decision
421
422
423 print("Example 26")

Callers 1

__aiter__Method · 0.95

Calls 1

sendMethod · 0.45

Tested by

no test coverage detected