summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2016-11-21 18:16:01 (GMT)
committerRaymond Hettinger <python@rcn.com>2016-11-21 18:16:01 (GMT)
commit8ab1258b585d0521e160be87b64c3417782d9e2d (patch)
treedb2f938293d9f75422914203d12405cfcf42b81f /Doc
parent23bb6f48ea30e805b558a4e03849c362029ca7c4 (diff)
downloadcpython-8ab1258b585d0521e160be87b64c3417782d9e2d.zip
cpython-8ab1258b585d0521e160be87b64c3417782d9e2d.tar.gz
cpython-8ab1258b585d0521e160be87b64c3417782d9e2d.tar.bz2
Simplify code in an example
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/random.rst12
1 files changed, 6 insertions, 6 deletions
diff --git a/Doc/library/random.rst b/Doc/library/random.rst
index 5492346..1bbf9a5 100644
--- a/Doc/library/random.rst
+++ b/Doc/library/random.rst
@@ -429,12 +429,12 @@ Simulation of arrival times and service deliveries in a single server queue::
num_waiting = 0
arrival = service_end = 0.0
- for i in range(10000):
- num_waiting += 1
- arrival += expovariate(1.0 / average_arrival_interval)
- print(f'{arrival:6.1f} arrived')
-
- while arrival > service_end:
+ for i in range(20000):
+ if arrival <= service_end:
+ num_waiting += 1
+ arrival += expovariate(1.0 / average_arrival_interval)
+ print(f'{arrival:6.1f} arrived')
+ else:
num_waiting -= 1
service_start = service_end if num_waiting else arrival
service_time = gauss(average_service_time, stdev_service_time)