Inspiration
The question "How do computers even generate random numbers??" popped into my mind when I was younger. I asked my dad about it and he explained a little about it (I didn't understand much). I later read about it and learnt that no computer can generate a true random number, which I thought was fascinating.
What it does
My code uses the datetime module and finds the current time. Then it gets the last digit of the current time converted to string. This works as a random number because the seconds given in the string are precise to eight digits. I also added a testing function that tests if the random function is random enough by calculating the average for 50 random numbers and checking if it is close enough to 5.
How we built it
The idea to use time suddenly popped into my head. It's not a very complicated idea, but I liked it so I started right away. First I created the random function which was easy enough and a bit too short. Python makes it possible for me to write the program in just two lines, but I wanted to make it look readable enough. After that I created the testing function.
Challenges we ran into
The testing function did not work as expected on my first try. Then I realized what I'd forgotten, getting the random function results in a for loop would not work without a certain amount of time passing between each iteration. So I googled what function I could use to force the program to wait, and I found it - time.sleep() from the time module.
Log in or sign up for Devpost to join the conversation.