
# WARNING:
# Generally, the Python Circular Import problem occurs when you accidentally 
# name your working file the same as the module name and those modules 
# depend on each other. This way the python opens the same file which 
# causes a circular loop and eventually throws an error.

#####################################################
# random(): uniform[0,1] random number generator:
#####################################################

import random
random.seed(10)  # this ensures we get the same results every time

four_uniform_randoms = [random.random() for _ in range(4)]

print(four_uniform_randoms)

##############################################################
# randrange(n): uniform[0,n) INTEGER random number generator:
##############################################################

for i in range(15):
    print(random.randrange(8), " ", end="")	# [0,8)
print("\n")


for i in range(15):
    print(random.randrange(3,8), " ", end="")	# [3,8)
print("\n")

#################################################################
# random.shuffle(LIST): randomly shuffles elements in a LIST (in place)
#################################################################

up_to_ten = [0,1,2,3,4,5,6,7,8,9]
print("Input: ", up_to_ten)

random.shuffle(up_to_ten)
print("Shuffled: ", up_to_ten)

print()


#################################################################
# random.choice(LIST): randomly SELECTS an element in a LIST 
#################################################################

up_to_ten = [0,1,2,3,4,5,6,7,8,9]
print("Input: ", up_to_ten)

x = random.choice(up_to_ten)
print("Choice: ", x)

print()


#################################################################
# Random sampling from n values WITHOUT replacement (no duplicates)
#################################################################

lottery_numbers = range(60)
winning_numbers = random.sample(lottery_numbers, 6) # [16, 36, 10, 6, 25, 9]
print(winning_numbers, "\n")

#################################################################
# Random sampling from n values WITH replacement (no duplicates)
#################################################################

# Just do random.choice() repeatedly:

lottery_numbers = range(60)
for i in range(6):
    print(random.choice(lottery_numbers), " ", end="" )
print()

out = [random.choice(lottery_numbers) for _ in range(6)]
print(out)



