For my coding project, I decided to make somewhat of a joke. I decided to code a program that allows the user to input a number, claiming to be able to read the user’s mind, when in reality, it’s just repeating the inputted number.
Flowchart:
1. Asks user to input a number
2. Pretends to think while displaying lines like “reading brainwaves”
3. “Guesses” the number by repeating whatever the user input
4. Asks if it was correct, and allows user to play again.
First, I imported “time” and “random” in order to be able to create delays in between messages, as well as pick random lines, which will be demonstrated shortly.
Next, I created the function “read_mind”, and added a short description.
This monstrosity of code was just my lazy attempt at making the program’s responses random. I didn’t want to figure out how to use %s and the like, so I just repeated each line a different amount of times, so that I could have rare lines like “Super rare message.”
This picks 3 lines from the line bank to display during the “loading” process.
This line is where all the magic happens, as the program repeats the inputted number to you, successfully reading your mind.
Finally, this whimsically asks the user whether or not it was right, even though it already knows. It concludes by asking the user if they would like to play again.
Leave a Reply