I wanted to create a short little piece of code so that I could see the biases in the random function.
import random
import statistics
import time
num = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
average = []
while True:
randomNum = random.randint(0, 9)
num[randomNum] += 1
average.append(randomNum)
print(f"\nThe average for all the numbers is {round(statistics.mean(average), round(sum(num) / 20))}") # The second part of the round function is to keep as few digits on screen while still showing changes with every number. 20 is the arbitrary number I found worked best.
print(f"The most common number is {num.index(max(num))}\n")
time.sleep(0.5)
Since I am new-ish to python I wanted to know if, even though its only 15 lines, that I am following good coding practices. That way when my code gets more complicated, I don't have to worry about that as much