-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRandom.py
29 lines (21 loc) · 865 Bytes
/
Random.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import datetime
import pytz # Required library for time zone support
def randomnum(time_zone):
# Getting the current time in the specified time zone
time_now = datetime.datetime.now(pytz.timezone(time_zone))
# Getting time in terms of microseconds
random_seed = time_now.microsecond
# An equation which returns a number between 0 and 10
seed = random_seed * 8 % 11
# Making random number somewhat unpredictable
random_micro_secs = []
for i in range(seed):
random_micro_secs.append(time_now.second**seed)
seed_2 = sum(random_micro_secs)
# Generating the final random number
truly_random_num = (seed_2 * 8 % 11)
return truly_random_num
# Example usage
time_zone = 'America/New_York' # Specify the desired time zone
random_number = randomnum(time_zone)
print(random_number)