From 665f56a430b08b69b9c319aaec099f9222c5583d Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Sat, 24 Oct 2020 11:56:48 -0500 Subject: [PATCH] avoid divide by 0 in getting pi simulation value --- pi/models.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pi/models.py b/pi/models.py index 0490748..210d8d9 100644 --- a/pi/models.py +++ b/pi/models.py @@ -59,6 +59,8 @@ class PiLog(models.Model): @property def value(self): """Return this log entry's estimated value of pi.""" + if self.total_count == 0: + return 0.0 return 4.0 * int(self.total_count_inside) / int(self.total_count) @property