Skip to content

Commit bc18ff4

Browse files
committed
new feture: you can get random number in range n times
1 parent 8baadf4 commit bc18ff4

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Scripts/rand_range.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,22 @@
33
import random
44
import sys
55

6+
print('----------------------------------------')
67
try:
7-
rand_min, rand_max = int(sys.argv[1]), int(sys.argv[2])
8+
rand_min, rand_max, n = int(sys.argv[1]), int(sys.argv[2]), ( int(sys.argv[3]) if len(sys.argv) > 3 else 1 )
89

9-
random_int = random.randint(rand_min, rand_max)
10-
print('random number:', random_int)
10+
random_ints = []
11+
12+
if n == 1:
13+
print('random number:', random.randint(rand_min, rand_max))
14+
else:
15+
for i in range(n):
16+
random_int = random.randint(rand_min, rand_max)
17+
print('\trandom number:', random_int)
18+
random_ints.append(random_int)
19+
20+
print('----------------------------------------')
21+
print(f'min: {min(random_ints)}, max: {max(random_ints)}, avg: {sum(random_ints)/len(random_ints)}')
1122

1223
except ValueError:
1324
print('only number like value are valid for min, max')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy